/* Mizan Land — mobile-first stylesheet. No build step. */
:root {
  --brand: #1f5f4a;
  --brand-2: #2b7a61;
  --brand-soft: #e7f2ee;
  --accent: #c8912e;
  --ink: #1d2521;
  --ink-2: #4b5751;
  --muted: #7a857f;
  --line: #dfe5e1;
  --bg: #f4f6f4;
  --card: #ffffff;
  --ok: #1e7a46;
  --ok-soft: #e3f4ea;
  --warn: #9a6400;
  --warn-soft: #fff4dc;
  --danger: #b3261e;
  --danger-soft: #fde8e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --tap: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.d-block { display: block; }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Top bar & navigation ───────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .5rem;
  height: 56px; padding: 0 12px;
  background: var(--brand); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.brand b { color: #f3d9a4; font-weight: 700; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 800;
}
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.icon-btn { background: none; border: 0; color: inherit; font-size: 1.4rem; width: var(--tap); height: var(--tap); cursor: pointer; }

.shell { display: block; }
.sidenav {
  position: fixed; top: 56px; bottom: 0; left: 0; width: 260px; z-index: 25;
  background: #fff; border-right: 1px solid var(--line); padding: .5rem 0 2rem; overflow-y: auto;
  transform: translateX(-100%); transition: transform .2s ease;
}
.sidenav.open { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.15); }
.sidenav a {
  display: flex; align-items: center; gap: .6rem; min-height: var(--tap);
  padding: 0 1rem; color: var(--ink); text-decoration: none; border-left: 3px solid transparent;
}
.sidenav a:hover { background: var(--bg); }
.sidenav a.active { background: var(--brand-soft); border-left-color: var(--brand); color: var(--brand); font-weight: 600; }
.sidenav .ni { width: 1.3rem; text-align: center; opacity: .8; }
.nav-head { padding: 1rem 1rem .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.main { padding: 16px; max-width: 1200px; margin: 0 auto; }
.hide-mobile { display: none; }

@media (min-width: 900px) {
  .only-mobile { display: none; }
  .hide-mobile { display: inline; }
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .sidenav { position: sticky; top: 56px; height: calc(100vh - 56px); transform: none; width: auto; }
  .main { padding: 24px 28px; width: 100%; }
}

/* ── Building blocks ─────────────────────────────── */
.page-head { margin-bottom: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.card.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.muted-card { background: #fafbfa; box-shadow: none; }
.grid-3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: .8rem; color: var(--muted); font-weight: 500; }
ul.plain { margin: 0; padding-left: 1.1rem; }
.warn-note { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: var(--tap); padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #b9c4be; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { color: var(--danger); border-color: #f0c4c0; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: .85rem; }
.btn-block { width: 100%; }
form.inline { display: inline; }

/* ── Forms ───────────────────────────────────────── */
.form-grid { display: grid; gap: 12px 16px; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
}
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-grid .field { margin-bottom: 0; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.field.check { flex-direction: row; align-items: flex-start; gap: .6rem; }
.field.check input { width: 20px; height: 20px; margin-top: 2px; }
input, select, textarea {
  font: inherit; font-size: 16px; /* 16px stops iOS zoom */
  min-height: var(--tap); padding: 8px 10px; width: 100%;
  border: 1px solid #c9d2cd; border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: var(--brand-2); }
.field-error { color: var(--danger); font-size: .82rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0; }
legend { font-weight: 600; padding: 0 .4rem; font-size: .9rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.filters { display: grid; gap: 8px 12px; grid-template-columns: 1fr 1fr; align-items: end; }
.filters .field { margin: 0; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(6, 1fr); } }

/* ── Area widget & display ───────────────────────── */
.area-input { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fbfcfb; }
.area-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 8px; }
.area-label { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid #c9d2cd; border-radius: 8px; overflow: hidden; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 5px 12px; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.seg input:checked + span { background: var(--brand); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.kms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kms label { display: flex; flex-direction: column; gap: 2px; }
.kms label[hidden] { display: none; }
.kms input { text-align: right; font-variant-numeric: tabular-nums; }
.kms span { font-size: .75rem; color: var(--muted); text-align: right; }
.area-preview { margin-top: 6px; min-height: 1.3em; }
.area-line { display: block; color: var(--ink-2); font-size: .8rem; line-height: 1.35; }
.area strong { font-variant-numeric: tabular-nums; }

/* ── Flash & badges ──────────────────────────────── */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef1ef; color: var(--ink-2); }
.badge-ok, .badge-create, .badge-login { background: var(--ok-soft); color: var(--ok); }
.badge-muted, .badge-logout { background: #eef1ef; color: var(--muted); }
.badge-owner { background: #f6ecd8; color: #7a5410; }
.badge-manager { background: #e3ecf8; color: #234f8c; }
.badge-accountant { background: #efe6f7; color: #5b2d86; }
.badge-field { background: var(--brand-soft); color: var(--brand); }
.badge-delete, .badge-override { background: var(--danger-soft); color: var(--danger); }
.badge-update, .badge-password { background: var(--warn-soft); color: var(--warn); }

/* ── Tables (stack into cards on phones) ─────────── */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfa; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { white-space: nowrap; text-align: right; }
@media (max-width: 699px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table.stack td { border: 0; padding: 4px 12px; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
  .table.stack td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: .8rem; text-align: left; }
  .table.stack td.actions { justify-content: flex-end; }
  .table.stack td.actions::before { content: none; }
}
.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; margin: 12px 0; }

/* ── Bare pages (login, installer) ───────────────── */
body.bare { background: linear-gradient(160deg, var(--brand) 0 280px, var(--bg) 280px); min-height: 100vh; }
.bare-main { max-width: 480px; margin: 0 auto; padding: 40px 16px; }
.bare-brand { color: #fff; font-size: 1.4rem; display: flex; gap: .5rem; align-items: center; justify-content: center; margin-bottom: 24px; }
.bare-brand b { color: #f3d9a4; }
.steps { display: flex; gap: .5rem; justify-content: center; margin-bottom: 16px; color: #fff; font-size: .85rem; }
.steps span { opacity: .6; } .steps span.on { opacity: 1; font-weight: 700; }

@media print {
  .topbar, .sidenav, .form-actions, .btn, .pager { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .card, .table-wrap { box-shadow: none; border-color: #999; }
}
