/* ==========================================================================
   GeoSentinels — visual identity
   Concept: a farm operations ledger. The record book on the office wall, not a
   fintech dashboard. Warm paper stock, ink-blue writing, a harvest-gold tab
   marker used sparingly. Headings in a condensed grotesque (signage/stencil
   lineage), body in a clean humanist sans, numbers in mono because this is a
   counting tool and figures should line up like a ledger column.
   ========================================================================== */

:root {
    --paper:      #f4f0e6;   /* aged paper background */
    --paper-2:    #eae4d5;   /* slightly deeper panel */
    --card:       #fbf9f3;   /* raised card, near-white paper */
    --ink:        #1f2a37;   /* ink blue-black, primary text */
    --ink-soft:   #55606e;   /* secondary text */
    --ink-faint:  #8b93a0;   /* captions */
    --line:       #d9d1bf;   /* hairline ruling */
    --line-2:     #c9bfa8;   /* stronger ruling */
    --blue:       #1d4e6f;   /* primary action, ink stamp blue */
    --blue-deep:  #163b54;
    --gold:       #c8912a;   /* harvest gold — the tab marker accent */
    --gold-soft:  #e9d9ac;
    --green:      #3f7d4e;   /* healthy / positive */
    --red:        #b0472f;   /* alert / negative */
    --shadow:     0 1px 0 rgba(0,0,0,.04), 0 12px 30px -20px rgba(31,42,55,.4);
    --radius:     7px;

    --font-display: 'Barlow Semi Condensed', 'Arial Narrow', sans-serif;
    --font-body:    'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:    'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    color: var(--ink);
    background:
        linear-gradient(var(--paper), var(--paper)),
        repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(180,165,130,.09) 31px, rgba(180,165,130,.09) 32px);
    background-attachment: fixed;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--ink);
    margin: 0;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- app shell ---------------------------------------------------------- */

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

.sidebar {
    width: 232px;
    flex: none;
    background: var(--ink);
    color: #d7ddE4;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 11px;
}
.brand .logo {
    width: 34px; height: 34px; flex: none;
    border: 1.5px solid var(--gold);
    border-radius: 6px;
    display: grid; place-items: center;
    color: var(--gold);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 19px;
    background: rgba(200,145,42,.08);
}
.brand .wordmark { font-family: var(--font-display); font-weight: 600; font-size: 20px; color: #fff; letter-spacing: .02em; line-height: 1; }
.brand .tag { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: #8f9aa8; margin-top: 3px; }

.nav { padding: 12px 12px; flex: 1; overflow-y: auto; }
.nav .group-label { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: #718096; padding: 14px 10px 6px; }
.nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px;
    border-radius: 6px;
    color: #c2cad4;
    font-size: 14px;
    margin-bottom: 2px;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav a.active { background: var(--blue); color: #fff; }
.nav a.active .ico { color: var(--gold); }
.nav .ico { width: 17px; height: 17px; flex: none; color: #8f9aa8; }
.nav a.active .ico, .nav a:hover .ico { color: inherit; }

.account {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; gap: 10px;
    font-size: 13px;
}
.account .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--gold); color: var(--ink);
    display: grid; place-items: center;
    font-family: var(--font-display); font-weight: 700; font-size: 13px;
    flex: none;
}
.account .who { line-height: 1.2; overflow: hidden; }
.account .who .n { color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account .who .f { color: #8f9aa8; font-size: 11px; }
.account .out { margin-left: auto; color: #8f9aa8; }
.account .out:hover { color: #fff; }

/* ---- main area ---------------------------------------------------------- */

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

.topbar {
    padding: 20px 32px 0;
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 20px;
}
.topbar .page-title { font-size: 28px; line-height: 1; }
.topbar .page-sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 6px; }
.content { padding: 22px 32px 48px; }

/* ---- flashes ------------------------------------------------------------ */

.flashes { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: 360px; pointer-events: none; }
.flash {
    padding: 12px 15px; border-radius: var(--radius);
    font-size: 14px; border: 1px solid; display: flex; gap: 9px; align-items: center;
    box-shadow: 0 12px 30px -12px rgba(31,42,55,.35); background: var(--card);
    pointer-events: auto; animation: flash-in .22s ease; position: relative;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.flash.hide-out { animation: flash-out .3s ease forwards; }
@keyframes flash-out { to { opacity: 0; transform: translateX(12px); } }
.flash .ico { width: 18px; height: 18px; flex: none; }
.flash > span:not(.flash-x) { flex: 1; line-height: 1.45; }
.flash .flash-x { margin-left: auto; cursor: pointer; color: currentColor; opacity: .5; flex: none; }
.flash .flash-x .ico { width: 15px; height: 15px; }
.flash .flash-x:hover { opacity: 1; }
.flash.ok  { background: #eaf3ec; border-color: #bcd8c2; color: #2f5d3a; }
.flash.err { background: #f6e7e2; border-color: #e0bcb0; color: #8f3720; }
@media (max-width: 560px) { .flashes { left: 12px; right: 12px; max-width: none; } }

/* ---- stat cards --------------------------------------------------------- */

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--gold);
}
.stat .label { font-size: 11px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-faint); }
.stat .value { font-family: var(--font-mono); font-size: 27px; font-weight: 500; margin-top: 7px; letter-spacing: -.02em; }
.stat .meta { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.stat.blue::before { background: var(--blue); }
.stat.green::before { background: var(--green); }
.stat.red::before { background: var(--red); }

/* ---- panels / tables ---------------------------------------------------- */

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.panel-head {
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    background: linear-gradient(var(--card), var(--paper-2));
}
.panel-head h3 { font-size: 17px; letter-spacing: .02em; }
.panel-head .sub { font-size: 12.5px; color: var(--ink-soft); }
.panel-body { padding: 4px 0; }
.panel-body.pad { padding: 20px; }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th {
    text-align: left; font-family: var(--font-display); font-weight: 600;
    font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--ink-soft); padding: 10px 20px; border-bottom: 1px solid var(--line-2);
}
table.grid th.r, table.grid td.r { text-align: right; }
table.grid td { padding: 12px 20px; border-bottom: 1px solid var(--line); }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: rgba(200,145,42,.05); }
table.grid td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.empty { padding: 40px 24px; text-align: center; color: var(--ink-soft); }
.empty h4 { font-size: 16px; margin-bottom: 6px; color: var(--ink); }
.empty p { font-size: 13.5px; max-width: 380px; margin: 0 auto 16px; }

/* ---- chips / badges ----------------------------------------------------- */

.chip {
    display: inline-block; padding: 2px 9px; border-radius: 20px;
    font-size: 11.5px; font-weight: 500; border: 1px solid var(--line-2);
    color: var(--ink-soft); background: var(--paper);
    font-family: var(--font-mono);
}
.chip.gold  { background: var(--gold-soft); border-color: #d8c078; color: #7a5b12; }
.chip.green { background: #e0efe3; border-color: #a9cdb0; color: #2f5d3a; }
.chip.red   { background: #f3ded7; border-color: #dcb3a4; color: #8f3720; }
.chip.blue  { background: #dde8ef; border-color: #a6c2d3; color: #1d4e6f; }

/* ---- buttons & forms ---------------------------------------------------- */

.btn {
    font-family: var(--font-body); font-size: 14px; font-weight: 500;
    padding: 9px 16px; border-radius: 6px; border: 1px solid var(--line-2);
    background: var(--card); color: var(--ink); cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
    transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: var(--paper-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--blue); border-color: var(--blue-deep); color: #fff; }
.btn.primary:hover { background: var(--blue-deep); }
.btn.gold { background: var(--gold); border-color: #a8760f; color: #2a1e05; }
.btn.gold:hover { background: #b47f16; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: #f3ded7; border-color: #dcb3a4; }

label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-soft); margin: 0 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
    width: 100%; font-family: var(--font-body); font-size: 14px;
    padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 6px;
    background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,78,111,.12);
}
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ---- modal (add forms) -------------------------------------------------- */

.modal-bg {
    position: fixed; inset: 0; background: rgba(31,42,55,.55);
    display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
    background: var(--card); border-radius: 10px; width: 100%; max-width: 520px;
    box-shadow: 0 30px 70px -20px rgba(0,0,0,.5); border: 1px solid var(--line-2);
    max-height: 90vh; overflow-y: auto;
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 20px; }
.modal-head p { font-size: 13px; color: var(--ink-soft); margin: 4px 0 0; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: var(--paper-2); }

/* ---- auth screen -------------------------------------------------------- */

.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-brand {
    background: var(--ink); color: #fff; padding: 56px 56px;
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-brand::after {
    content: ''; position: absolute; inset: 0;
    background:
        repeating-linear-gradient(90deg, transparent, transparent 46px, rgba(255,255,255,.03) 46px, rgba(255,255,255,.03) 47px),
        repeating-linear-gradient(0deg, transparent, transparent 46px, rgba(255,255,255,.03) 46px, rgba(255,255,255,.03) 47px);
    pointer-events: none;
}
.auth-brand .top, .auth-brand .bottom { position: relative; z-index: 1; }
.auth-brand .logo-lg {
    width: 46px; height: 46px; border: 2px solid var(--gold); border-radius: 9px;
    display: grid; place-items: center; color: var(--gold);
    font-family: var(--font-display); font-weight: 700; font-size: 26px;
    margin-bottom: 26px; background: rgba(200,145,42,.1);
}
.auth-brand h1 { color: #fff; font-size: 46px; line-height: 1.02; margin-bottom: 18px; max-width: 12ch; }
.auth-brand .lede { color: #b9c2cd; font-size: 16px; max-width: 42ch; line-height: 1.55; }
.auth-brand .modules { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.auth-brand .modules .m { font-size: 12px; color: #cfd6df; border: 1px solid rgba(255,255,255,.16); padding: 4px 11px; border-radius: 20px; font-family: var(--font-mono); }
.auth-brand .foot { color: #7f8a98; font-size: 12.5px; }

.auth-form-side { display: grid; place-items: center; padding: 40px; background: var(--paper); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.auth-card .p { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }
.auth-card .switch { margin-top: 20px; font-size: 13.5px; color: var(--ink-soft); text-align: center; }
.auth-card .fine { font-size: 12px; color: var(--ink-faint); margin-top: 18px; text-align: center; line-height: 1.5; }

/* ---- misc --------------------------------------------------------------- */

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.searchbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.searchbar .search-input { width: 240px; padding: 8px 11px; font-size: 13.5px; }
.searchbar select { width: auto; padding: 8px 10px; font-size: 13px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .right { display: flex; gap: 8px; align-items: center; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
.spacer { flex: 1; }
.hide { display: none; }

@media (max-width: 1000px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
}
@media (max-width: 760px) {
    .sidebar { display: none; }
    .stat-row { grid-template-columns: 1fr 1fr; }
    .content, .topbar, .flashes { padding-left: 18px; padding-right: 18px; }
    .field-row, .field-row-3 { grid-template-columns: 1fr; }
}
