:root {
  --bg: #f3f6f4;
  --text: #122018;
  --sub: #667085;
  --primary: #1b7a52;
  --primary-dark: #145c3d;
  --border: #dde5df;
  --card: #ffffff;
  --sidebar: #0e2a21;
  --danger: #b42318;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; }
h1, h2, h3 { margin: 0; }
p { margin: 0; line-height: 1.55; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #12372b 0%, #0c241c 100%);
  color: #dff7ea;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 4px 4px 18px;
  margin: 0 2px;
  border-bottom: 1px solid rgba(168, 178, 172, 0.32);
}
.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.brand-name {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: #f3fff8;
}
.brand-name span {
  font-weight: 500;
  color: #9fd4b8;
}
.brand small {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(201, 224, 210, 0.72);
}
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(145deg, #2f9e68 0%, #1a6f48 55%, #145539 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 8px 18px rgba(0, 0, 0, 0.22);
}
.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #eafff3;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand:hover .brand-mark {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16) inset,
    0 10px 20px rgba(0, 0, 0, 0.26);
}
.brand-mark,
.brand:hover .brand-mark {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.65;
  padding: 0 10px;
}
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  text-decoration: none;
  color: #d5efdf;
}
.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.07); }
.sidebar-nav a.active {
  background: rgba(46, 180, 118, 0.18);
  color: #effff7;
}
.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}
.user-card { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar, .mobile-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.86rem;
  background: #21634b;
  color: #e5fff4;
}
.mobile-avatar {
  display: none;
}
.user-copy { display: flex; flex-direction: column; min-width: 0; }
.user-copy strong {
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.user-copy small { font-size: 0.72rem; opacity: 0.75; }
.logout-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: #e7fff4;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.logout-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.logout-button:hover { background: rgba(255, 255, 255, 0.1); }

.page-shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(243, 246, 244, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.topbar-copy h1 {
  font-size: 1.15rem;
  margin: 0;
}
.topbar-date {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--sub);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.farm-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.farm-switcher-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sub);
  font-weight: 700;
}
.farm-switcher select {
  min-width: 180px;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-wrap-sm { height: 260px; }

@media (max-width: 900px) {
  .chart-wrap,
  .chart-wrap-sm { height: 240px; }
}
.is-selected-row { background: #f3fbf7; }
.farm-context-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
.farm-context-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.farm-context-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sub);
}
.farm-context-copy h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.farm-context-meta {
  margin: 2px 0 0;
  color: var(--sub);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.4;
}
.farm-context-filter {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}
.farm-context-filter label {
  display: grid;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--sub);
  letter-spacing: 0.02em;
}
.farm-context-filter input[type="date"] {
  padding: 0.45rem 0.6rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fafbfa;
  font-size: 0.86rem;
  color: var(--text);
  min-width: 138px;
}
.farm-context-filter input[type="date"]:focus {
  background: #fff;
  border-color: #8fc4aa;
  box-shadow: 0 0 0 3px rgba(27, 122, 82, 0.1);
}
.farm-context-filter button {
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 650;
  background: #eef5f1;
  color: #175a3d;
  border: 1px solid #d5e6dc;
  min-width: 96px;
  position: relative;
}
.farm-context-filter button:hover {
  background: #e3efe8;
  color: #124a32;
}
.farm-context-filter button:disabled {
  opacity: 0.75;
  cursor: wait;
}
.farm-context-banner.is-loading {
  pointer-events: none;
}
.dashboard-live {
  display: grid;
  gap: 16px;
  position: relative;
  transition: opacity 0.2s ease;
}
.dashboard-live.is-loading {
  opacity: 0.55;
  pointer-events: none;
}
.dashboard-live.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  background-size: 200% 100%;
  animation: dashboard-shimmer 1.1s linear infinite;
  pointer-events: none;
}
@keyframes dashboard-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.farm-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.farm-switcher-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sub);
  font-weight: 700;
}
.farm-switcher select {
  min-width: 180px;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

@media (max-width: 900px) {
  .farm-switcher-label { display: none; }
  .farm-switcher select { min-width: 140px; }
}
.menu-toggle {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: none;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.menu-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #334155;
  stroke-width: 2;
  stroke-linecap: round;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  border: none;
  display: none;
  z-index: 25;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  gap: 16px;
}

/* Cards / panels */
.panel,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--sub);
}
.card strong {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h2,
.panel > h2,
.panel > h3 {
  margin-bottom: 4px;
  font-size: 1.05rem;
}
.panel-head p,
.muted {
  color: var(--sub);
  font-size: 0.9rem;
}
.page-stack { display: grid; gap: 16px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Forms */
.grid-form {
  display: grid;
  gap: 12px 14px;
  align-items: end;
}
.grid-form.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-form.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-form.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #344054;
}
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

/* Shared clean forms (farms, expenses, …) */
.farm-form,
.clean-form {
  display: grid;
  gap: 18px;
}
.farm-form-tabs,
.clean-form-tabs {
  display: inline-flex;
  width: fit-content;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: #e7ede9;
}
.farm-form-tab,
.clean-form-tab {
  border: none;
  background: transparent !important;
  color: var(--sub);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 650;
  box-shadow: none;
}
.farm-form-tab:hover,
.clean-form-tab:hover {
  color: var(--text);
  background: transparent !important;
}
.farm-form-tab.active,
.clean-form-tab.active {
  background: #fff !important;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
.farm-form-panel-body,
.clean-form-panel {
  display: grid;
  gap: 14px;
}
.farm-form-panel-body[hidden],
.clean-form-panel[hidden] {
  display: none !important;
}
.farm-form-grid,
.clean-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.farm-field,
.clean-field {
  display: grid;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 650;
  color: #344054;
}
.farm-field-full,
.clean-field-full { grid-column: 1 / -1; }
.farm-field input,
.farm-field select,
.farm-field textarea,
.clean-field input,
.clean-field select,
.clean-field textarea {
  font-weight: 500;
  color: var(--text);
  background: #fbfcfb;
  border-color: #d7e0db;
}
.farm-field input:focus,
.farm-field select:focus,
.farm-field textarea:focus,
.clean-field input:focus,
.clean-field select:focus,
.clean-field textarea:focus {
  background: #fff;
}
.farm-field textarea,
.clean-field textarea {
  min-height: 110px;
  resize: vertical;
}
.farm-form-actions,
.clean-form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}
.farm-form-actions button,
.clean-form-actions button {
  min-width: 140px;
}
.clean-form-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.clean-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 10px;
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
}
.clean-check input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: #1b7a52;
}
.members-page td strong {
  margin-right: 8px;
}

/* Searchable type-select */
.type-select {
  position: relative;
}
.type-select-input {
  width: 100%;
}
.type-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 240px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
  display: grid;
  gap: 2px;
}
.type-select-menu[hidden] {
  display: none !important;
}
.type-select-option {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.7rem;
  border: none;
  border-radius: 9px;
  background: transparent !important;
  color: var(--text);
  box-shadow: none;
  font-weight: 500;
}
.type-select-option strong {
  font-size: 0.9rem;
  font-weight: 650;
}
.type-select-option small {
  color: var(--sub);
  font-size: 0.75rem;
}
.type-select-option:hover,
.type-select-option.is-active {
  background: #f3f8f5 !important;
}
.type-select-empty {
  padding: 0.7rem;
  color: var(--sub);
  font-size: 0.84rem;
  text-align: center;
}
.type-select.is-open .type-select-input {
  border-color: #8fc4aa;
  box-shadow: 0 0 0 3px rgba(27, 122, 82, 0.1);
}
@media (max-width: 720px) {
  .farm-form-grid,
  .clean-form-grid {
    grid-template-columns: 1fr;
  }
}

.farms-list,
.records-list {
  display: grid;
  gap: 12px;
}
.farms-list-head h2,
.records-list-head h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.farms-action-cell {
  width: 1%;
  white-space: nowrap;
}
.farms-action-cell form {
  margin: 0;
}
.farms-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.farm-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0.4rem 0.85rem;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
}
.farm-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.farm-action-select {
  border: 1px solid #cfe4d8;
  background: #f3faf6;
  color: #176447;
  box-shadow: none;
}
.farm-action-select:hover {
  background: #e6f5ec;
  border-color: #b7d9c6;
  color: #114c35;
}
.farm-action-map {
  border: 1px solid #d7dde8;
  background: #f5f7fb;
  color: #3b4a63;
}
.farm-action-map:hover {
  background: #eef2f8;
  border-color: #c5cedc;
  color: #243247;
}
.farm-action-selected {
  border: 1px solid transparent;
  background: #e8f7ef;
  color: #147a4d;
}
.farm-action-muted {
  color: var(--sub);
  font-weight: 600;
  font-size: 0.82rem;
}
input,
select,
textarea,
button {
  font: inherit;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid #cfd8d3;
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #8fc4aa;
  box-shadow: 0 0 0 4px rgba(27, 122, 82, 0.12);
}
button {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  padding: 0.72rem 1rem;
}
button:hover { background: var(--primary-dark); }
.btn-secondary,
.btn-ghost,
.btn-danger {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 600;
}
.btn-secondary { background: #eef8f2; border-color: #c9e8d8; color: #175a3d; }
.btn-ghost { background: transparent; }
.btn-danger { background: #fff5f5; border-color: #f3c4c4; color: #9f2d2d; }
.panel-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.btn-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn-link:hover { text-decoration: underline; }
.inline-form {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f4;
  text-align: left;
  font-size: 0.9rem;
  vertical-align: middle;
}
th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #667085;
  background: #f8faf9;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fcfb; }

/* Toast alerts */
.toast-stack {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: auto;
  padding: 16px;
  pointer-events: none;
}
.toast {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  padding: 14px 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--sub);
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.toast-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.82rem;
  background: #eef2f6;
  color: #475467;
}
.toast-copy { display: grid; gap: 3px; min-width: 0; }
.toast-title { font-size: 0.92rem; }
.toast-message {
  font-size: 0.88rem;
  color: var(--sub);
  overflow-wrap: anywhere;
}
.toast-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #98a2b3;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.toast-close:hover { background: #f2f4f7; color: #475467; }
.toast-close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.toast-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  transform-origin: left center;
  background: currentColor;
  opacity: 0.35;
  animation: toast-countdown linear forwards;
}
.toast.is-paused .toast-timer { animation-play-state: paused; }
.toast-success { border-left-color: #12805c; color: #12805c; }
.toast-success .toast-icon { background: #d1fadf; color: #087443; }
.toast-error { border-left-color: #b42318; color: #b42318; }
.toast-error .toast-icon { background: #fee4e2; color: #b42318; }
.toast-warning { border-left-color: #b54708; color: #b54708; }
.toast-warning .toast-icon { background: #fef0c7; color: #b54708; }
.toast-info { border-left-color: #175cd3; color: #175cd3; }
.toast-info .toast-icon { background: #d1e9ff; color: #175cd3; }
.toast-title { color: var(--text); }

@keyframes toast-countdown {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Settings */
.settings-page {
  display: grid;
  gap: 20px;
  width: 100%;
  max-width: none;
}
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.settings-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sub);
  font-weight: 700;
}
.settings-seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: #e7ede9;
}
.settings-seg a {
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  color: var(--sub);
  font-size: 0.84rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.settings-seg a:hover { color: var(--text); }
.settings-seg a.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
.settings-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
}
.settings-panel-top {
  margin-bottom: 14px;
}
.settings-panel-top h3 {
  font-size: 0.98rem;
  font-weight: 650;
  margin-bottom: 2px;
}
.settings-panel-top p {
  color: var(--sub);
  font-size: 0.84rem;
}
.settings-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) auto;
  gap: 8px;
  align-items: center;
}
.settings-add input {
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  border-color: #d5ddd8;
  background: #fff;
}
.settings-add button {
  white-space: nowrap;
  padding: 0.55rem 1rem;
  border-radius: 9px;
  font-size: 0.88rem;
}
.settings-table {
  min-width: 560px;
}
.settings-table .col-index {
  width: 56px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}
.settings-table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
.settings-table th.col-actions {
  text-align: right;
}
.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
th.col-actions {
  text-align: right;
}
.detail-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.detail-grid > div {
  display: grid;
  gap: 2px;
}
.detail-grid dt {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.detail-grid dd {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
  word-break: break-word;
}
.modal-card-detail {
  width: min(420px, 100%);
}
.modal-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.contact-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.contact-icon {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: var(--sub);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.contact-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.contact-icon:hover {
  background: #f0f4f1;
  color: var(--text);
}
.contact-icon-phone:hover { color: #147a4d; }
.contact-icon-email:hover { color: #175cd3; }
.settings-cat {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.settings-cat strong {
  font-weight: 650;
}
.settings-desc-cell {
  color: var(--sub);
}
.settings-table tr.is-inactive td {
  color: #98a2b3;
}
.settings-table tr.is-inactive .settings-desc-cell {
  color: #b0b7c3;
}
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--sub);
  white-space: nowrap;
}
.status-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #98a2b3;
}
.status-dot.on { color: #147a4d; }
.status-dot.on::before { background: #18a864; }
.status-dot.off { color: #98a2b3; }
.settings-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.settings-actions form { margin: 0; }
.btn-icon {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent !important;
  color: var(--sub);
  box-shadow: none;
}
.btn-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-icon:hover {
  background: #f0f4f1 !important;
  color: var(--text);
}
.btn-icon.danger { color: #b42318; }
.btn-icon.danger:hover {
  background: #fff1f0 !important;
  color: #912018;
}
.btn-text {
  background: transparent !important;
  border: none;
  color: var(--sub);
  padding: 0.35rem 0.5rem;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.8rem;
  box-shadow: none;
}
.btn-text:hover {
  background: #f0f4f1 !important;
  color: var(--text);
}
.btn-text.danger { color: #b42318; }
.btn-text.danger:hover {
  background: #fff1f0 !important;
  color: #912018;
}
.settings-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--sub);
  font-size: 0.9rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted { background: #e2e8f0; color: #475569; }
.hint {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--sub);
}

@media (max-width: 720px) {
  .settings-add {
    grid-template-columns: 1fr;
  }
}
.hint a { color: var(--primary); font-weight: 600; text-decoration: none; }
.empty-state {
  padding: 18px;
  color: var(--sub);
  text-align: center;
}
.breakdown-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.breakdown-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8faf9;
  border: 1px solid #e8eee9;
}

/* Confirmation modal */
body.modal-open { overflow: hidden; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.modal.is-open {
  visibility: visible;
  opacity: 1;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(3px);
  cursor: default;
}
.modal-backdrop:hover { background: rgba(15, 23, 42, 0.52); }
.modal-card {
  position: relative;
  width: min(430px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  transform: translateY(10px) scale(0.98);
  transition: transform 0.18s ease;
}
.modal.is-open .modal-card { transform: translateY(0) scale(1); }
.modal-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin-bottom: 16px;
}
.modal-icon-danger {
  color: #b42318;
  background: #fee4e2;
  border: 6px solid #fef3f2;
}
.modal-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.modal-copy { display: grid; gap: 7px; }
.modal-copy h2 { font-size: 1.15rem; }
.modal-copy p { color: var(--sub); font-size: 0.92rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.modal-confirm-button {
  background: #b42318;
  color: #fff;
}
.modal-confirm-button:hover { background: #912018; }
.modal-card-form {
  width: min(480px, 100%);
}
.modal-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.modal-field {
  display: grid;
  gap: 6px;
}
.modal-field span {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--sub);
}
.modal-form .modal-actions {
  margin-top: 8px;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-close {
  flex-shrink: 0;
  margin-top: -4px;
}
.modal-card-create {
  width: min(520px, 100%);
}
.modal-card-create .clean-form {
  margin-top: 16px;
}
.modal-card-create .clean-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 40;
  width: 56px;
  height: 56px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #1b7a52;
  color: #fff;
  box-shadow: 0 10px 28px rgba(27, 122, 82, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.fab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fab:hover {
  background: #146343;
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(27, 122, 82, 0.4);
}
.fab:focus-visible {
  outline: 2px solid #102e24;
  outline-offset: 3px;
}

/* Auth */
.auth-shell { display: grid; grid-template-columns: 1.05fr 0.95fr; min-height: 100vh; }
.auth-visual {
  padding: 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(900px 500px at 10% -20%, rgba(76, 175, 128, 0.35), transparent 55%),
    linear-gradient(145deg, #102e24 0%, #174636 100%);
  color: #dbf8e9;
}
.brand-light .brand-mark {
  background: linear-gradient(145deg, #3cb87a 0%, #1f8a56 55%, #167048 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18) inset,
    0 10px 24px rgba(0, 0, 0, 0.18);
}
.brand-light .brand-name { color: #ffffff; }
.brand-light .brand-name span { color: #c8f0d8; }
.brand-light small { color: rgba(232, 255, 242, 0.78); }
.auth-message { max-width: 520px; }
.auth-kicker {
  display: inline-block;
  padding: 0.34rem 0.62rem;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.14);
  margin-bottom: 14px;
}
.auth-message h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 10px;
}
.auth-message p { max-width: 440px; opacity: 0.9; }
.auth-tagline { opacity: 0.72; }
.auth-content { display: grid; place-items: center; padding: 24px; }
.auth-content-inner { width: min(460px, 100%); }
.auth-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  display: grid;
  gap: 14px;
}
.auth-panel h2 { font-size: 1.35rem; }
.auth-panel p a { color: var(--primary); font-weight: 600; text-decoration: none; }

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .menu-toggle { display: grid; }
  .mobile-avatar { display: grid; }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .container { padding: 16px; }
  .stats-grid,
  .grid-form.cols-2,
  .grid-form.cols-3,
  .grid-form.cols-4 {
    grid-template-columns: 1fr;
  }
  .col-span-2,
  .col-span-3,
  .col-span-4 { grid-column: span 1; }
  .panel-head { flex-direction: column; }
}
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
}
