/* Mahallu Manager — admin UI */
:root {
  --brand: #0f5c4d;
  --brand-600: #0b4a3e;
  --brand-100: #e2f0ec;
  --brand-50: #f0f7f5;
  --amber: #a8620f;
  --amber-100: #fbeed8;
  --ink: #1b2823;
  --ink-2: #3d4d46;
  --muted: #6a7973;
  --line: #e1e7e3;
  --line-2: #cfd8d3;
  --bg: #f3f5f2;
  --card: #ffffff;
  --danger: #b42318;
  --danger-100: #fdecea;
  --ok: #17803d;
  --ok-100: #e5f5ea;
  --info-100: #e8f0fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 40, 33, .06), 0 1px 3px rgba(15, 40, 33, .05);
  --shadow-lg: 0 12px 40px rgba(15, 40, 33, .18);
  --font: 'Inter', 'Noto Sans Malayalam', 'Nirmala UI', 'Segoe UI', system-ui, sans-serif;
  --font-ml: 'Noto Sans Malayalam', 'Nirmala UI', 'Kartika', 'Inter', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: #eef2ef; padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.ml { font-family: var(--font-ml); }
.ic { flex: none; vertical-align: -3px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0c4a3e 0%, #093a31 100%); color: #cfe3dd; padding: 18px 12px 12px;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 4px 8px 18px; color: #fff; text-decoration: none !important; }
.brand b { display: block; font-size: 15px; font-weight: 650; }
.brand small { display: block; font-family: var(--font-ml); font-size: 12px; color: #9dc4b9; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: #f1c46b; color: #5a3a05; font-family: var(--font-ml); font-weight: 700; font-size: 19px;
}
.sidebar nav { flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #7fa89b; padding: 16px 10px 6px; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
  color: #cfe3dd; font-weight: 500; text-decoration: none !important;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: inset 3px 0 0 #f1c46b; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me { display: flex; align-items: center; gap: 9px; min-width: 0; }
.me b { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 112px; }
.me small { display: block; font-size: 11.5px; color: #8fb7ab; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #1d7a67; color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.foot-actions { display: flex; gap: 4px; }
.foot-actions form { margin: 0; }
.sidebar .icon-btn { color: #b6d3ca; }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 54px; display: flex; align-items: center; gap: 10px; padding: 0 28px; border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 242, .9); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 20;
}
.crumbs { color: var(--muted); font-size: 13.5px; }
.crumbs span { margin: 0 4px; opacity: .6; }
.crumbs b { color: var(--ink); font-weight: 600; }
.menu-btn { display: none; }
.content { padding: 26px 28px 60px; max-width: 1280px; width: 100%; }
.scrim { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px;
  border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: inherit; font-weight: 550;
  cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: #f6f8f6; border-color: #b9c6c0; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #3d9c86; outline-offset: 1px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-danger { color: var(--danger); border-color: #f0c4bf; }
.btn-danger:hover { background: var(--danger-100); border-color: #e7a8a1; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 7px; border: 0; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center; cursor: pointer; text-decoration: none !important;
}
.icon-btn:hover { background: #e9eeea; color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-100); color: var(--danger); }
.icon-btn[disabled], .icon-btn.disabled { opacity: .35; pointer-events: none; }
form.inline { display: inline; margin: 0; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h2, .card-h h3 { flex: 1; }
.card-b { padding: 18px; }
.card + .card { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-main { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; }
.stat .ico { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-100); color: var(--brand); flex: none; }
.stat.amber .ico { background: var(--amber-100); color: var(--amber); }
.stat .n { font-size: 26px; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }

/* ---------- forms ---------- */
.field { display: block; }
.field > span { display: block; font-weight: 550; margin-bottom: 5px; font-size: 13.5px; }
.field > span em { font-style: normal; color: var(--muted); font-weight: 400; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 12.5px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff;
  font: inherit; color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 80px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #3d9c86; box-shadow: 0 0 0 3px rgba(61, 156, 134, .18); outline: none; }
input.ml, textarea.ml, select.ml { font-family: var(--font-ml); }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 38px; height: 22px; border-radius: 22px; background: #c5cfca; position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid #3d9c86; outline-offset: 2px; }
.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- badges / pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: #edf1ee; color: var(--ink-2); white-space: nowrap; }
.pill.green { background: var(--brand-100); color: var(--brand); }
.pill.amber { background: var(--amber-100); color: var(--amber); }
.pill.red { background: var(--danger-100); color: var(--danger); }
.pill.blue { background: var(--info-100); color: #1d4f9c; }
.pill.gray { background: #edf1ee; color: var(--muted); }
.qno { display: inline-block; min-width: 30px; text-align: center; padding: 1px 7px; border-radius: 6px; background: var(--amber-100); color: var(--amber); font-weight: 700; font-size: 12px; }
.qno.none { background: #eef2ef; color: #a2afa9; }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; margin-bottom: 16px; border: 1px solid; }
.alert > span { flex: 1; }
.alert-success { background: var(--ok-100); border-color: #bfe3cb; color: #14532d; }
.alert-error { background: var(--danger-100); border-color: #f3c3be; color: #7a1c13; }
.alert-info { background: var(--info-100); border-color: #c7d8f2; color: #1b3d73; }
.alert-warn { background: var(--amber-100); border-color: #f0d6a8; color: #6b3d06; }
.alert-x { border: 0; background: transparent; color: inherit; opacity: .6; cursor: pointer; padding: 2px; }
.alert-x:hover { opacity: 1; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfa; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcfb; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: 20px; }
.tab { padding: 10px 16px; font-weight: 550; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none !important; display: flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .pill { margin-left: 2px; }

/* ---------- form builder ---------- */
.section-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.section-card.inactive { opacity: .72; }
.section-card.drag-over { outline: 2px dashed #3d9c86; outline-offset: 2px; }
.section-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 12px; border-bottom: 1px solid var(--line); background: #fafcfb; border-radius: var(--radius) var(--radius) 0 0; }
.section-h .titles { flex: 1; min-width: 0; }
.section-h .t { font-family: var(--font-ml); font-weight: 650; font-size: 16px; }
.section-h .en { color: var(--muted); font-size: 12.5px; }
.section-actions { display: flex; align-items: center; gap: 2px; }
.q-list { list-style: none; margin: 0; padding: 0; min-height: 14px; }
.q-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 8px; border-bottom: 1px solid var(--line); background: #fff; }
.q-item:last-child { border-bottom: 0; }
.q-item.dragging { opacity: .4; }
.q-item.drop-before { box-shadow: 0 -2px 0 #3d9c86; }
.q-item.inactive .q-label { text-decoration: line-through; color: var(--muted); }
.q-item:hover { background: #fbfdfc; }
.grip { color: #9fb0a9; cursor: grab; display: grid; place-items: center; width: 22px; flex: none; }
.grip:active { cursor: grabbing; }
.q-main { flex: 1; min-width: 0; }
.q-label { font-family: var(--font-ml); font-weight: 550; line-height: 1.4; }
.q-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.q-actions { display: flex; align-items: center; gap: 1px; flex: none; }
.q-add { padding: 10px 14px; border-top: 1px dashed var(--line); }
.q-empty { padding: 22px; text-align: center; color: var(--muted); }

/* option editor */
.opt-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.opt-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: 0 6px 6px; font-weight: 600; }
.opt-table td { padding: 3px 4px; vertical-align: middle; }
.opt-table input[type=text] { height: 36px; }
.opt-table .code { width: 64px; text-align: center; font-weight: 600; }
.opt-table tr.dragging { opacity: .4; }
.opt-table tr.drop-before td { box-shadow: 0 -2px 0 #3d9c86; }
.opt-table tr.off input[type=text] { color: var(--muted); background: #f6f8f6; }
.opt-flag { text-align: center; width: 56px; }
.opt-table th.opt-flag { font-size: 10.5px; padding: 0 2px 6px; letter-spacing: .02em; }
.opt-table input[type=text]:not(.code) { min-width: 150px; }
.opt-table .chk-big { width: 17px; height: 17px; accent-color: var(--brand); }
.opt-tools { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }

.callout { padding: 12px 14px; border-radius: 9px; background: var(--brand-50); border: 1px solid #cfe5df; color: #1f5144; font-size: 13.5px; }
.callout.warn { background: var(--amber-100); border-color: #f0d6a8; color: #6b3d06; }
.callout b { font-weight: 600; }

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.type-opt { position: relative; }
.type-opt input { position: absolute; opacity: 0; }
.type-opt label { display: block; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 9px; cursor: pointer; background: #fff; height: 100%; }
.type-opt label b { display: block; font-size: 13.5px; font-weight: 600; }
.type-opt label small { color: var(--muted); font-size: 12px; }
.type-opt input:checked + label { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 2px rgba(15, 92, 77, .15); }
.type-opt input:focus-visible + label { outline: 2px solid #3d9c86; outline-offset: 1px; }
.type-opt input:disabled + label { opacity: .5; cursor: not-allowed; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.sticky-side { position: sticky; top: 70px; }

/* modal */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 28px)); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog::backdrop { background: rgba(10, 30, 25, .45); backdrop-filter: blur(2px); }
.modal-h { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h2 { flex: 1; }
.modal-b { padding: 20px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fafcfb; border-radius: 0 0 14px 14px; }

/* chips list (areas) */
.zone-card .area-row { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.zone-card .area-row:last-child { border-bottom: 0; }
.zone-card .area-row .nm { flex: 1; font-family: var(--font-ml); }
.zone-card .area-row.off .nm { color: var(--muted); text-decoration: line-through; }

/* bars */
.bar-row { display: grid; grid-template-columns: 190px 1fr 36px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13.5px; }
.bar-row .lab { font-family: var(--font-ml); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 10px; background: #edf1ee; border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #2c8a76, #0f5c4d); border-radius: 6px; }
.bar.amber i { background: linear-gradient(90deg, #e0a043, #a8620f); }

ul.clean { list-style: none; margin: 0; padding: 0; }
ul.clean li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
ul.clean li:last-child { border-bottom: 0; }
ul.steps { list-style: none; padding: 0; margin: 16px 0; }
ul.steps li { display: flex; gap: 8px; align-items: center; padding: 5px 0; color: var(--ok); }

/* toast */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #11332b; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 14px; animation: tin .2s ease-out; max-width: 340px; }
.toast.err { background: #8d1f15; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* auth */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(900px 500px at 10% -10%, #d6ebe4 0%, transparent 60%),
  radial-gradient(800px 500px at 110% 110%, #f6e3bd 0%, transparent 55%), var(--bg); }
.auth-card { width: 100%; max-width: 410px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px 30px 28px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.auth-brand b { display: block; font-size: 16px; } .auth-brand small { color: var(--muted); font-family: var(--font-ml); }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card .muted { margin-bottom: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 1050px) { .grid-main { grid-template-columns: 1fr; } .sticky-side { position: static; } .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 30, 25, .45); z-index: 50; }
  .menu-btn { display: inline-grid; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .col-8, .col-6, .col-4, .col-3 { grid-column: span 12; }
  .bar-row { grid-template-columns: 120px 1fr 30px; }
  .q-actions .hide-sm { display: none; }
}
