:root {
  --primary: #39a34b;
  --accent: #136a6c;
  --sidebar-bg: #082f30;
  --btn: #136a6c;
  --btn-hover: #0f5658;
  --bg: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --card: #ffffff;
  --radius: 11px;
  --shadow: 0 4px 24px rgba(8, 47, 48, 0.08);
  --shadow-sm: 0 1px 3px rgba(8, 47, 48, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.75rem;
}

.sidebar-brand strong {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: #fff;
}

.sidebar-brand span {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 0.2rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.25rem;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: rgba(57, 163, 75, 0.18);
  border-left-color: var(--primary);
  color: #fff;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  opacity: 0.9;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid #e5e7eb;
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.global-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 0.35rem 0.65rem;
  min-width: 220px;
}

.global-search input {
  border: none;
  background: transparent;
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
}

.content {
  padding: 1.5rem 1.75rem 2.5rem;
  flex: 1;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid #eef2f6;
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
}

.card-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.settings-page {
  max-width: 720px;
}

.settings-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.settings-panel-actions {
  margin-top: 0.25rem;
}

.settings-accordion > details {
  border: 1px solid #d1d9e0;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(8, 47, 48, 0.06);
  overflow: hidden;
}

.settings-accordion > details > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.9rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  background: #eef6f0;
  border-bottom: 1px solid #c8d9cc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  user-select: none;
}

.settings-accordion > details > summary::-webkit-details-marker {
  display: none;
}

.settings-accordion > details > summary::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  flex-shrink: 0;
  transition: transform 0.2s ease;
  margin-top: -0.15rem;
}

.settings-accordion > details[open] > summary {
  border-bottom-color: #c8d9cc;
  background: #e4f0e8;
}

.settings-accordion > details[open] > summary::after {
  transform: rotate(45deg);
  margin-top: 0.1rem;
}

.settings-accordion .accordion-body {
  padding: 1.15rem 1.2rem 1.35rem;
  background: #fff;
  border-top: 1px solid #e8eeea;
}

.settings-accordion .accordion-body > p.help {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--btn);
  color: #fff;
}
.btn-primary:hover {
  background: var(--btn-hover);
  color: #fff;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid #d1d5db;
}
.btn-ghost:hover {
  background: #f3f4f6;
  text-decoration: none;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.btn-danger {
  background: #b91c1c;
  color: #fff;
}
.btn-danger:hover {
  background: #991b1b;
  color: #fff;
  text-decoration: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem 1rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
}

.form-group textarea {
  min-height: 72px;
  resize: vertical;
}

.table-wrap {
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid #e5e7eb;
  max-height: calc(100vh - 220px);
}

table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

table.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sidebar-bg);
  color: #fff;
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

table.data-table tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid #eef2f6;
  vertical-align: middle;
}

table.data-table tbody tr:nth-child(even) td {
  background: #f9fafb;
}

table.data-table tbody tr:hover td {
  background: #f0fdf4;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-new {
  background: #dbeafe;
  color: #1e40af;
}
.badge-warn {
  background: #fef3c7;
  color: #92400e;
}
.badge-ok {
  background: #d1fae5;
  color: #065f46;
}
.badge-bad {
  background: #fee2e2;
  color: #991b1b;
}
.badge-muted {
  background: #f3f4f6;
  color: #4b5563;
}

.row-highlight-soon td {
  box-shadow: inset 3px 0 0 var(--primary);
}
.row-highlight-overdue td {
  box-shadow: inset 3px 0 0 #dc2626;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  border: 1px solid #eef2f6;
}

.stat-card .label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--accent);
  margin-top: 0.25rem;
  letter-spacing: -0.02em;
}

.stat-card .value.money::before {
  content: "₹ ";
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
}

.section-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 25px 50px rgba(8, 47, 48, 0.18);
  border: 1px solid #e5e7eb;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(145deg, #082f30 0%, #136a6c 45%, #39a34b 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
  padding: 2rem;
}

.auth-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  color: var(--text);
}

.auth-card .sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem;
  }
  .sidebar-brand {
    width: 100%;
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0.5rem;
  }
  .nav-link {
    flex: 1 1 auto;
    justify-content: center;
    border-left: none;
    border-bottom: 3px solid transparent;
  }
  .nav-link.active {
    border-left: none;
    border-bottom-color: var(--primary);
  }
}
