:root {
  --ink: #10251c;
  --green: #1d6d50;
  --green-dark: #124936;
  --green-soft: #e7f2ec;
  --cream: #f6f4ed;
  --paper: #fff;
  --line: #dfe5df;
  --muted: #66736d;
  --danger: #b42318;
  --warning: #a15c00;
  --shadow: 0 10px 30px rgba(16, 37, 28, .06);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  margin: 0;
}
a { color: var(--green-dark); }
button, input, select, textarea { font: inherit; }

.topbar {
  align-items: center;
  background: var(--ink);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .16);
  display: flex;
  gap: 18px;
  min-height: 64px;
  padding: 10px clamp(16px, 3vw, 38px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { color: #fff; font-size: 1.12rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.brand span { color: #9bc7b4; font-size: .78rem; font-weight: 600; margin-left: 4px; }
.main-nav { display: flex; flex: 1; flex-wrap: wrap; gap: 2px; }
.main-nav a, .logout {
  border-radius: 7px;
  color: #dce9e2;
  font-size: .85rem;
  padding: 8px 9px;
  text-decoration: none;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; }
.logout { border: 1px solid rgba(255,255,255,.35); }
.menu-toggle { display: none; }

.page { margin: 0 auto; max-width: 1540px; padding: 28px clamp(14px, 3vw, 38px) 60px; }
.auth-page { align-items: center; display: flex; min-height: 100vh; justify-content: center; }
.page-heading { align-items: flex-start; display: flex; gap: 18px; justify-content: space-between; margin-bottom: 22px; }
.page-heading h1 { font-size: clamp(1.6rem, 2.5vw, 2.25rem); letter-spacing: -.035em; margin: 0; }
.page-heading p { color: var(--muted); margin: 5px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }
.metric, .panel, .table-card, .auth-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
}
.metric { min-height: 112px; padding: 18px; }
.metric-label { color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.metric-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.025em; margin-top: 6px; }
.panel, .table-card { margin-bottom: 18px; padding: 18px; }
.panel h2, .table-card h2 { font-size: 1.1rem; margin: 0 0 14px; }
.auth-card { max-width: 430px; padding: 28px; width: 100%; }
.auth-card h1 { margin-top: 0; }
.muted { color: var(--muted); }

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.field { grid-column: span 3; }
.field.wide { grid-column: span 6; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; font-size: .84rem; font-weight: 700; margin-bottom: 5px; }
.control {
  background: #fff;
  border: 1px solid #cbd6cf;
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}
textarea.control { min-height: 92px; resize: vertical; }
.control:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,109,80,.13); outline: 0; }
.checkbox { align-items: center; display: flex; gap: 8px; min-height: 42px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.btn {
  align-items: center;
  background: #fff;
  border: 1px solid #b9c7bf;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  gap: 6px;
  justify-content: center;
  min-height: 39px;
  padding: 8px 13px;
  text-decoration: none;
}
.btn:hover { background: #f3f6f4; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { border-color: #e7aaa5; color: var(--danger); }
.btn-small { font-size: .78rem; min-height: 32px; padding: 5px 9px; }
.inline-form { display: inline; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid #e8ece9; padding: 10px 9px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:hover { background: #f8faf8; }
td.actions-cell { text-align: right; white-space: nowrap; }
.number { font-variant-numeric: tabular-nums; text-align: right; }
.thumb { background: #f7faf7; border: 1px solid var(--line); height: 58px; object-fit: contain; width: 90px; }

.badge { border-radius: 999px; display: inline-block; font-size: .75rem; font-weight: 800; padding: 4px 8px; white-space: nowrap; }
.badge-neutral { background: #edf1ef; color: #43514a; }
.badge-success { background: #dff3e8; color: #17603f; }
.badge-warning { background: #fff0d6; color: #854c00; }
.badge-danger { background: #fde7e5; color: #9d1c14; }
.alert { border-radius: 9px; margin-bottom: 15px; padding: 12px 14px; }
.alert-success { background: #dff3e8; color: #155e3f; }
.alert-danger { background: #fde7e5; color: #8e1b14; }
.alert-warning { background: #fff0d6; color: #734300; }
.alert-info { background: #e7f0f6; color: #264e66; }
.empty-state { background: #fff; border: 1px dashed #bfc9c3; border-radius: 12px; color: var(--muted); padding: 32px; text-align: center; }
.progress { background: #e5ebe7; border-radius: 999px; height: 8px; overflow: hidden; min-width: 110px; }
.progress > span { background: var(--green); display: block; height: 100%; }
.danger-text { color: var(--danger); font-weight: 700; }
.warning-text { color: var(--warning); font-weight: 700; }
.success-text { color: var(--green); font-weight: 700; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs a { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; text-decoration: none; }
.tabs a.active { background: var(--ink); color: #fff; }
.line-table .control { min-width: 110px; }
.line-table .description { min-width: 220px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(105px, 1fr)); min-width: 735px; }
.calendar-day { border: 1px solid var(--line); min-height: 110px; padding: 7px; }
.calendar-day.muted-day { background: #f6f8f6; color: #8b9690; }
.calendar-event { background: var(--green-soft); border-left: 3px solid var(--green); border-radius: 4px; font-size: .76rem; margin-top: 4px; overflow: hidden; padding: 3px 5px; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1100px) {
  .field { grid-column: span 4; }
  .field.wide { grid-column: span 8; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-nav { display: none; left: 12px; position: absolute; right: 12px; top: 58px; }
  .main-nav.open { background: var(--ink); border-radius: 10px; display: grid; padding: 10px; }
  .menu-toggle { background: transparent; border: 1px solid rgba(255,255,255,.35); border-radius: 7px; color: #fff; display: block; margin-left: auto; padding: 7px 10px; }
}

@media (max-width: 720px) {
  .page { padding-top: 20px; }
  .page-heading { display: block; }
  .page-heading .actions { margin-top: 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .field, .field.wide { grid-column: 1 / -1; }
  .logout { display: none; }
  th, td { padding: 9px 7px; }
}
