/* Component styles. Layout utilities come from Tailwind (CDN). */
:root {
  --ink: #15231d; --muted: #5b6b64; --line: #dde5e1; --paper: #f3f6f4;
  --brand: #0b5d4b; --brand-dark: #08463a; --leaf: #e3f1ec;
  --amber: #a86400; --amber-bg: #fdf0d5; --red: #b42318; --red-bg: #fde8e6; --green-bg: #dcf3e6;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif; background: var(--paper); color: var(--ink); font-size: 15px; }
h1, h2, h3 { letter-spacing: -0.01em; }

/* Layout: sidebar + main */
.app { display: flex; min-height: 100vh; }
#sidebar { width: 15.5rem; flex-shrink: 0; background: #0d2b24; color: #cfe3dc; display: flex; flex-direction: column; padding: 1.1rem .8rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#sidebar .brand { padding: .2rem .6rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: .8rem; }
#sidebar .brand b { display: block; font-size: 1.25rem; color: #fff; }
#sidebar .brand span { font-size: .8rem; color: #8fb5a8; }
.nav-link { display: flex; align-items: center; gap: .65rem; padding: .6rem .7rem; border-radius: .5rem; color: #cfe3dc; text-decoration: none; font-weight: 600; margin-bottom: .15rem; }
.nav-link:hover { background: rgba(255,255,255,.08); }
.nav-link.active { background: var(--leaf); color: var(--brand-dark); }
.side-user { margin-top: auto; padding: .8rem .6rem 0; border-top: 1px solid rgba(255,255,255,.12); font-size: .85rem; }
.side-user button { margin-top: .5rem; width: 100%; }
.main { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.menu-btn { display: none; }
@media (max-width: 860px) {
  #sidebar { position: fixed; z-index: 40; left: 0; transform: translateX(-100%); transition: transform .2s; }
  #sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 1rem .8rem 3rem; }
}

/* Cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: .6rem; padding: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: .6rem; padding: .9rem 1rem; }
.stat .k { color: var(--muted); font-size: .85rem; }
.stat .v { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .95rem; border-radius: .45rem; font: inherit; font-weight: 600; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-dark); }
.btn:focus-visible, .input:focus-visible, .nav-link:focus-visible { outline: 3px solid #9fd3c3; outline-offset: 1px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-light { background: #fff; color: var(--ink); border-color: #c5d1cc; }
.btn-light:hover { background: #eef3f1; }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #8f1c12; }
.btn-sm { padding: .28rem .6rem; font-size: .85rem; }

/* Forms */
.label { display: block; font-size: .85rem; font-weight: 600; color: #38453f; margin-bottom: .25rem; }
.input { width: 100%; border: 1px solid #b9c7c1; border-radius: .45rem; padding: .5rem .65rem; font: inherit; background: #fff; color: var(--ink); }
.input:focus { border-color: var(--brand); }
.form-error { background: var(--red-bg); color: var(--red); border-radius: .45rem; padding: .55rem .75rem; margin-bottom: .75rem; font-size: .9rem; display: none; }
.form-error.show { display: block; }

/* Tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; padding: .6rem .7rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:hover td { background: #f7faf8; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge-green { background: var(--green-bg); color: #116a39; }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: #e8edea; color: #46534d; }

/* Modals */
.modal-back { position: fixed; inset: 0; background: rgba(13,43,36,.55); display: none; align-items: flex-start; justify-content: center; padding: 1.5rem 1rem; z-index: 60; overflow-y: auto; }
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: .7rem; width: 100%; max-width: 42rem; padding: 1.25rem; margin: auto; }
.modal h2 { margin: 0; font-size: 1.15rem; }

/* Toasts */
#toasts { position: fixed; top: 1rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: 22rem; }
.toast { background: #fff; border-left: 5px solid var(--brand); border-radius: .45rem; padding: .7rem .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.toast.error { border-left-color: var(--red); }

/* Loading */
.spinner { width: 1.1rem; height: 1.1rem; border: 3px solid #c9d8d2; border-top-color: var(--brand); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } #sidebar { transition: none; } }

.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tab { padding: .55rem 1rem; font-weight: 600; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; color: var(--muted); font: inherit; font-weight: 600; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

@media print { #sidebar, .no-print, .menu-btn { display: none !important; } .main { padding: 0; } body { background: #fff; } .card { border: 0; } }
