/* AASWAAS app: same tokens as aaswaas.com (public/styles.css). Mobile-first: designed for phones, widened for desktop. */
:root {
  --bg: #EEF3EF; --surface: #FFFFFF; --ink: #14302A; --muted: #4B6A60; --rule: #C9D9CF;
  --green: #0B4A33; --on-green: #FFFFFF; --green-soft: #D5E6DC; --peach: #F6E3C2;
  --marigold: #FFD24A; --on-marigold: #14302A; --danger: #A1261B; --danger-soft: #F8DEDA;
  --display: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1F1A; --surface: #152B24; --ink: #E6EFEA; --muted: #A3BDB2; --rule: #2A4B40;
    --green: #86C9AB; --on-green: #0E1F1A; --green-soft: #1D3A31; --peach: #3A3222;
    --danger: #F2A49A; --danger-soft: #3B1E1A;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 1.0625rem; line-height: 1.5; overflow-wrap: anywhere; }
a, button, input, select, textarea, label { touch-action: manipulation; }
h1, h2, h3 { margin: 0; font-family: var(--display); line-height: 1.15; letter-spacing: -0.015em; overflow-wrap: normal; }
h1 { font-size: clamp(1.6rem, 6vw, 2.4rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--green); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: 46rem; margin: 0 auto; padding-inline: 16px; }
.wrap.wide { max-width: 75rem; }
main.wrap { padding-block: 1.25rem 3rem; }
body.has-tabbar main.wrap { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 1.5rem); }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.danger { color: var(--danger); }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.25rem; }
@media (min-width: 760px) { .stack-lg > * + * { margin-top: 2rem; } main.wrap { padding-top: 1.75rem; } }

/* ---------- Header ---------- */
.app-header { background: var(--surface); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 10; padding-top: env(safe-area-inset-top, 0px); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; max-width: 75rem; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-family: var(--display); font-weight: 800; letter-spacing: 0.12em; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand small { letter-spacing: 0.04em; font-weight: 600; color: var(--muted); font-size: 0.82rem; }
.brand svg { width: 2rem; height: 2rem; }
.header-end { display: flex; align-items: center; gap: 1.25rem; }
.app-nav { display: none; align-items: center; gap: 1.25rem; font-size: 0.95rem; }
.app-nav.always { display: flex; }
.app-nav a { color: var(--ink); font-weight: 700; text-decoration: none; padding: 0.35rem 0; }
.app-nav a:hover, .app-nav a[aria-current="page"] { color: var(--green); text-decoration: underline; text-underline-offset: 6px; }
.signout { margin: 0; }
.linklike { background: none; border: 0; padding: 0.5rem 0; font: inherit; font-size: 0.92rem; font-weight: 700; color: var(--muted); cursor: pointer; text-decoration: underline; }
@media (min-width: 760px) { .app-nav { display: flex; } }

/* ---------- Bottom tab bar (phones) ---------- */
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 10; display: flex; background: var(--surface); border-top: 1px solid var(--rule);
  padding-bottom: var(--safe-b); box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabbar-h);
  color: var(--muted); text-decoration: none; font-size: 0.75rem; font-weight: 700; }
.tabbar a[aria-current="page"] { color: var(--green); }
.tabbar a[aria-current="page"] svg { background: var(--green-soft); border-radius: 999px; padding: 2px 14px; box-sizing: content-box; }
@media (min-width: 760px) { .tabbar { display: none; } body.has-tabbar main.wrap { padding-bottom: 3rem; } }

/* ---------- Page heading ---------- */
.page-head > * + * { margin-top: 0.5rem; }
.page-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.page-head h1 .pill { font-family: "Atkinson Hyperlegible", system-ui, sans-serif; letter-spacing: 0; }
.back { display: inline-block; font-weight: 700; text-decoration: none; padding: 0.25rem 0; }

/* ---------- Cards and lists ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 16px; padding: 1rem; }
.card > * + * { margin-top: 0.85rem; }
@media (min-width: 760px) { .card { padding: 1.25rem; } }
details.card > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
details.card > summary::after { content: "▾"; color: var(--muted); }
details.card[open] > summary::after { content: "▴"; }
details > summary { cursor: pointer; padding: 0.3rem 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.cols { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .cols { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; } }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
@media (min-width: 960px) { .list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.list-item { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  color: var(--ink); text-decoration: none; }
.list-item:hover { border-color: var(--green); }
.list-item:active { transform: scale(0.995); }
.li-top { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.li-title { font-weight: 700; }
.li-meta { color: var(--muted); font-size: 0.92rem; }
.li-next { margin-top: 0.3rem; color: var(--green); font-weight: 700; font-size: 0.92rem; }
.empty { padding: 2rem 0; text-align: center; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 50px; padding: 0 1.4rem; border-radius: 999px; border: 0; background: var(--marigold); color: var(--on-marigold); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center; line-height: 1.2; }
.btn:hover { filter: brightness(0.95); }
.btn:active { transform: scale(0.98); }
.btn-green { background: var(--green); color: var(--on-green); }
.btn-outline { background: transparent; color: var(--ink); border: 2px solid currentColor; }
.btn-danger { background: transparent; color: var(--danger); border: 2px solid currentColor; }
.btn-sm { min-height: 42px; padding: 0 1rem; font-size: 0.95rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.btn-block { width: 100%; }
@media (max-width: 759px) {
  .card .btn-row > .btn, .card .btn-row > form, .notice .btn { flex: 1 1 auto; }
  .card .btn-row > form > .btn { width: 100%; }
  .notice > .btn { width: 100%; }
}

/* ---------- Forms ---------- */
form.stack > * + * { margin-top: 1rem; }
fieldset { border: 1px solid var(--rule); border-radius: 14px; padding: 1rem; margin: 0; min-width: 0; background: var(--surface); }
fieldset > * + * { margin-top: 1rem; }
legend { font-family: var(--display); font-weight: 700; font-size: 1.1rem; padding: 0 0.4rem; }
.field { display: block; }
.field .label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
.field .hint { display: block; font-size: 0.88rem; color: var(--muted); margin-top: 0.3rem; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=email], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 0.6rem 0.8rem; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: max(16px, 1rem); -webkit-appearance: none; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--green-soft); border-color: var(--green); }
.radio-list { display: grid; gap: 0.5rem; }
.radio-list label { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.75rem 0.85rem; border: 1.5px solid var(--rule); border-radius: 12px; cursor: pointer; }
.radio-list label:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.radio-list input { margin-top: 0.3rem; accent-color: var(--green); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.2rem 0; }
.check input { margin-top: 0.3rem; accent-color: var(--green); width: 1.2rem; height: 1.2rem; flex: none; }
.two { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.filters { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.5rem; align-items: center; }
.filters input[type=search] { grid-column: 1 / -1; }
@media (min-width: 760px) { .filters { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; } .filters input[type=search] { grid-column: auto; } }
.filters select { grid-column: span 2; }
@media (min-width: 760px) { .filters select { grid-column: auto; } }

/* Status tabs: one scrollable row on phones */
.tabs { display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding: 0.1rem 16px; scroll-snap-type: x proximity; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; scroll-snap-align: start; padding: 0.5rem 0.9rem; border-radius: 999px; border: 1.5px solid var(--rule); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.tabs a[aria-current="page"] { background: var(--green); border-color: var(--green); color: var(--on-green); }
.tabs .count { opacity: 0.75; margin-left: 0.2rem; }
@media (min-width: 760px) { .tabs { flex-wrap: wrap; margin-inline: 0; padding-inline: 0; } }

/* Template chips on the update box */
.chips { display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; margin-inline: -1rem; padding-inline: 1rem; }
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 760px) { .chips { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; } }
.chip { flex: none; padding: 0.45rem 0.85rem; border-radius: 999px; border: 1.5px solid var(--rule); background: var(--bg); color: var(--ink); font: inherit; font-size: 0.88rem; font-weight: 700; cursor: pointer; }
.chip.on { background: var(--green-soft); border-color: var(--green); }

/* Bill form */
.bill-rows { display: grid; gap: 0.5rem; }
.bill-row { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem; gap: 0.5rem; }
.bill-row input[type=number] { text-align: right; }
.bill-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 0.6rem; border-top: 2px solid var(--rule); font-size: 1.15rem; }

/* Companion candidates */
.cand-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.cand-list li { border: 1px solid var(--rule); border-radius: 12px; padding: 0.75rem; display: grid; gap: 0.4rem; }
.cand-list li.blocked { opacity: 0.7; }
.cand-pick { display: flex; gap: 0.6rem; align-items: flex-start; }
.cand-pick input { width: 1.25rem; height: 1.25rem; margin-top: 0.2rem; accent-color: var(--green); flex: none; }

/* ---------- Notices, pills, tables ---------- */
.notice { border-radius: 12px; padding: 0.9rem 1rem; background: var(--green-soft); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.warn { background: var(--peach); }
.notice ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }

.estimate { border: 2px solid var(--green); border-radius: 14px; padding: 1rem; }
.estimate table { width: 100%; border-collapse: collapse; }
.estimate td { padding: 0.25rem 0; vertical-align: top; }
.estimate td:last-child { text-align: right; white-space: nowrap; padding-left: 1rem; }
.estimate .total td { border-top: 1px solid var(--rule); padding-top: 0.5rem; font-weight: 700; }

.pill { display: inline-block; padding: 0.15rem 0.65rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; background: var(--green-soft); color: var(--ink); white-space: nowrap; }
.pill-new, .pill-applied, .pill-pending, .pill-completed, .pill-billed { background: var(--marigold); color: var(--on-marigold); }
.pill-cancelled, .pill-lost, .pill-rejected, .pill-suspended, .pill-expired { background: var(--danger-soft); color: var(--danger); }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 14px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th, table.data td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
table.data tr:last-child td { border-bottom: 0; }
table.data a { font-weight: 700; }
/* Phones: each table row becomes a card; app.js copies the column name into data-label. */
@media (max-width: 640px) {
  .table-wrap { border: 0; background: none; overflow: visible; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 0.6rem 0.8rem; margin-bottom: 0.5rem; }
  table.data td { border: 0; padding: 0.25rem 0; }
  table.data td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
  table.data input[type=date] { width: 100% !important; }
}

/* Details lists: label above value on phones */
dl.kv { display: grid; grid-template-columns: 1fr; gap: 0.15rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 0.85rem; margin-top: 0.55rem; }
dl.kv dt:first-child { margin-top: 0; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 560px) {
  dl.kv { grid-template-columns: minmax(7rem, max-content) 1fr; gap: 0.4rem 1rem; }
  dl.kv dt { margin-top: 0; font-size: 1rem; }
}
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 0.45rem 0 0.45rem 1rem; border-left: 3px solid var(--green-soft); font-size: 0.95rem; }
.ref { font-family: ui-monospace, Menlo, monospace; font-weight: 700; letter-spacing: 0.04em; }
.big-code { font-size: 2rem; font-family: ui-monospace, Menlo, monospace; letter-spacing: 0.2em; font-weight: 700; }
.qr { width: 200px; height: 200px; background: #fff; padding: 10px; border-radius: 12px; }
.qr img, .qr canvas { width: 100%; height: 100%; }

/* Installed app (standalone): no text selection flicker on controls */
@media (display-mode: standalone) { .btn, .tabbar a, .chip, .tabs a { -webkit-user-select: none; user-select: none; } }

/* Malayalam */
:lang(ml) body, html:lang(ml) body { font-family: "Atkinson Hyperlegible", "Noto Sans Malayalam", system-ui, sans-serif; line-height: 1.65; }
html:lang(ml) h1, html:lang(ml) h2, html:lang(ml) h3 { font-family: "Bricolage Grotesque", "Noto Sans Malayalam", system-ui, sans-serif; line-height: 1.35; letter-spacing: 0; }
html:lang(ml) h1 { font-size: clamp(1.45rem, 5.5vw, 2.1rem); }
.lang-switch { display: inline-flex; align-items: center; min-height: 36px; padding: 0 0.8rem; border: 1.5px solid var(--rule); border-radius: 999px;
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: 0.9rem; font-family: "Noto Sans Malayalam", "Atkinson Hyperlegible", system-ui, sans-serif; white-space: nowrap; }
.lang-switch:hover { border-color: var(--green); color: var(--green); }
.header-end { gap: 0.75rem; }
@media (min-width: 760px) { .header-end { gap: 1.25rem; } }
.brand > span, .linklike, .lang-switch { white-space: nowrap; }
@media (max-width: 479px) {
  .brand small { display: none; }
  .header-end { gap: 0.6rem; }
  .lang-switch { padding: 0 0.65rem; min-height: 34px; font-size: 0.85rem; }
}
