/* Pavia BPLO resident portal — design system.
 *
 * Who this is for: a small business owner in Pavia, on a phone, doing an
 * unfamiliar government task once a year. Every decision below serves being
 * understood by someone who is not sure they are doing it right.
 *
 * The palette is Pavia BPLO's own — the dark green and warm cream of the app
 * residents already use (BPLO/lib/utilities/global.dart) — not the municipal
 * seal's navy. The seal is the LGU's crest; the green is this service.
 *
 * ELEVATION IS DECLARED ONCE. A surface is either bordered or raised, never
 * both: a 1px border under a wide soft shadow is a smudge, not depth. Flat
 * bordered panels are the page; shadow is reserved for things that genuinely
 * float above it.
 */

/* ---------------------------------------------------------------- tokens - */

:root {
  --brand:       #146b2b;
  --brand-deep:  #0e5420;
  --brand-soft:  #28a745;
  --brand-tint:  #e6f2e9;
  --brand-wash:  #f2f9f4;

  --gold:        #d79d11;
  --gold-tint:   #fdf3d9;

  --ink:         #1b2318;
  --ink-2:       #495245;
  --ink-3:       #6f7a6c;
  --line:        #ded9c9;
  --line-soft:   #ebe6d7;

  --bg:          #faf5e9;
  --surface:     #ffffff;
  --surface-2:   #fffdf7;

  --danger:      #a8271f;
  --danger-bg:   #fceceb;
  --warn:        #8a5d00;
  --warn-bg:     #fdf2da;
  --ok:          #146b2b;
  --ok-bg:       #e6f2e9;
  --info:        #1f5673;
  --info-bg:     #e8f1f7;

  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;

  /* The only shadow. Offset and blur, never a zero-offset halo. */
  --lift:  0 6px 16px -6px rgba(27,35,24,.18), 0 2px 5px -2px rgba(27,35,24,.10);
  --lift-hi: 0 18px 40px -14px rgba(27,35,24,.26), 0 4px 10px -4px rgba(27,35,24,.12);

  --ease: cubic-bezier(.16,1,.3,1);
  --maxw: 1040px;

  --tap: 48px;   /* the floor for anything a thumb must hit */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 "Source Sans 3", -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ------------------------------------------------------------ typography - */

h1, h2, h3 {
  font-family: Lexend, "Source Sans 3", sans-serif;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.022em;
  text-wrap: balance;
  margin: 0 0 .35em;
  color: var(--ink);
}
h1 { font-size: clamp(1.7rem, 1.25rem + 2vw, 2.4rem); }
h2 { font-size: clamp(1.2rem, 1.05rem + .6vw, 1.45rem); }
h3 { font-size: 1.06rem; letter-spacing: -.012em; }

/* More room above a heading than below it: the gap belongs to what follows. */
* + h2 { margin-top: 1.9em; }
* + h3 { margin-top: 1.5em; }

p { margin: 0 0 1.05em; max-width: 68ch; }
a { color: var(--brand); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { color: var(--brand-deep); }

.muted  { color: var(--ink-3); }
.small  { font-size: .9rem; line-height: 1.5; }
.tiny   { font-size: .8rem; line-height: 1.45; }
.tabular{ font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.lede   { font-size: 1.08rem; color: var(--ink-2); max-width: 60ch; }

/* ---------------------------------------------------------------- layout - */

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
main  { padding: 26px 0 96px; }

.grid { display: grid; gap: 16px; }
@media (min-width: 700px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid.cols-3 { grid-template-columns: repeat(3,1fr); } }

.row    { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end{ justify-content: flex-end; }
.spread { display: flex; gap: 14px; align-items: center;
          justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.grow { flex: 1 1 auto; min-width: 0; }

/* --------------------------------------------------------------- top bar - */

.topbar { background: var(--brand-deep); color: #fff; }
.topbar .wrap { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.topbar a { color: rgba(255,255,255,.88); text-decoration: none; }
.topbar a:hover { color: #fff; }

.brand { display: flex; align-items: center; gap: 11px; color: #fff !important;
         font-family: Lexend; font-weight: 600; letter-spacing: -.01em; }
.brand .mark {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  background: var(--gold); color: var(--brand-deep);
  display: grid; place-items: center; font: 700 15px/1 Lexend;
  letter-spacing: 0;
}
.brand small { display: block; font: 400 11px/1.2 "Source Sans 3";
               color: rgba(255,255,255,.72); letter-spacing: .06em;
               text-transform: uppercase; }

.topnav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.topnav a, .topnav button {
  padding: 9px 13px; border-radius: 9px; font: 600 15px/1 "Source Sans 3";
  background: transparent; border: 0; cursor: pointer; color: rgba(255,255,255,.88);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.topnav a:hover, .topnav button:hover { background: rgba(255,255,255,.12); color:#fff; }
.topnav .current { background: rgba(255,255,255,.16); color: #fff; }

@media (max-width: 640px) {
  .topnav { gap: 0; }
  .topnav a, .topnav button { padding: 9px 9px; font-size: 14px; }
  .brand small { display: none; }
}

/* -------------------------------------------------------------- surfaces - */
/* Bordered OR raised. Never both. */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px;
}
.card.pad-lg { padding: 28px; }
.card > :first-child { margin-top: 0; }
.card > :last-child  { margin-bottom: 0; }

/* A card that is a link or a button gets its lift on interaction only. */
.card-link {
  display: block; text-decoration: none; color: inherit; background: var(--surface);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              border-color .18s var(--ease);
}
.card-link:hover {
  border-color: var(--brand-soft); box-shadow: var(--lift);
  transform: translateY(-2px);
}
.card-link:active { transform: translateY(0); }

/* Inside a card, a group is separated by space and a rule — not another card. */
.group + .group { margin-top: 20px; padding-top: 20px;
                  border-top: 1px solid var(--line-soft); }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 12px; }
.section-title h2 { margin: 0; }

hr.sep { border: 0; border-top: 1px solid var(--line-soft); margin: 22px 0; }

/* --------------------------------------------------------------- buttons - */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--tap); padding: 12px 20px;
  border-radius: var(--r-sm); border: 1.5px solid transparent;
  font: 600 16px/1 "Source Sans 3"; cursor: pointer; text-decoration: none;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              color .16s var(--ease), transform .12s var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 19px; height: 19px; flex: 0 0 auto; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-deep); }
.btn-ghost   { background: var(--surface); color: var(--brand-deep);
               border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-wash); }
.btn-quiet   { background: transparent; color: var(--ink-3); border-color: transparent;
               min-height: 40px; padding: 8px 12px; }
.btn-quiet:hover:not(:disabled) { color: var(--ink); background: rgba(27,35,24,.05); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8d1f18; }
.btn-block   { width: 100%; }
.btn-sm      { min-height: 38px; padding: 8px 14px; font-size: 14.5px; }

/* ----------------------------------------------------------------- forms - */

.field { display: block; margin-bottom: 18px; }
.field > span, .field > label, .label {
  display: block; font-weight: 600; font-size: .95rem; margin-bottom: 7px;
  color: var(--ink);
}
.field > span .muted, .field > label .muted { font-weight: 400; }
.field .hint { font-size: .875rem; color: var(--ink-3); margin: 6px 0 0; }

/* `input:not([type])` matters: an <input> with no type IS a text input, but no
   [type=text] selector matches it, and half this project's fields omit it. */
input:not([type]), input[type=text], input[type=tel], input[type=email],
input[type=number], input[type=password], input[type=date], input[type=search],
select, textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
input::placeholder, textarea::placeholder { color: #98a195; }
input:hover:not(:disabled), select:hover, textarea:hover { border-color: #c9c3ae; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(40,167,69,.18);
}
input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--danger); box-shadow: 0 0 0 4px rgba(168,39,31,.14);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
select { appearance: none; padding-right: 42px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23495245' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  background-size: 18px; }

fieldset { border: 1px solid var(--line); border-radius: var(--r);
           padding: 18px; margin: 0 0 18px; }
legend { font-weight: 600; padding: 0 8px; font-size: .95rem; }

.code-input {
  font: 600 27px/1 "Source Sans 3"; letter-spacing: .42em;
  text-align: center; padding: 14px 10px 14px 24px;
  font-variant-numeric: tabular-nums;
}

.check { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px;
         padding: 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
         cursor: pointer; transition: border-color .16s var(--ease),
                                      background .16s var(--ease); }
.check:hover { border-color: var(--brand-soft); background: var(--brand-wash); }
.check input[type=checkbox] { width: 21px; height: 21px; margin: 1px 0 0;
                              flex: 0 0 auto; accent-color: var(--brand); }
.check > span { flex: 1 1 auto; }

input[type=file] {
  width: 100%; padding: 14px; font: inherit; color: var(--ink-3);
  background: var(--surface-2); border: 2px dashed var(--line);
  border-radius: var(--r-sm); cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
input[type=file]:hover { border-color: var(--brand-soft); background: var(--brand-wash); }
input[type=file]:focus { outline: none; border-color: var(--brand);
                         box-shadow: 0 0 0 4px rgba(40,167,69,.18); }
input[type=file]::file-selector-button {
  font: 600 14.5px/1 "Source Sans 3"; margin-right: 14px; padding: 10px 16px;
  border: 0; border-radius: 8px; cursor: pointer;
  background: var(--brand); color: #fff;
}
input[type=file]::file-selector-button:hover { background: var(--brand-deep); }

/* ---------------------------------------------------------------- status - */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  font-size: .82rem; font-weight: 600; white-space: nowrap; line-height: 1.3;
}
.pill svg { width: 14px; height: 14px; }
.pill-ok     { background: var(--ok-bg);     color: var(--ok); }
.pill-warn   { background: var(--warn-bg);   color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-info   { background: var(--info-bg);   color: var(--info); }
.pill-quiet  { background: var(--line-soft); color: var(--ink-2); }

.note {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--r-sm); padding: 15px 17px; font-size: .96rem;
  border: 1px solid transparent; margin-bottom: 16px;
}
.note svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.note > div { flex: 1 1 auto; min-width: 0; }
.note p:last-child { margin-bottom: 0; }
.note-info   { background: var(--info-bg);   border-color: #cfe0ec; color: #17405a; }
.note-warn   { background: var(--warn-bg);   border-color: #eedcae; color: #6d4900; }
.note-danger { background: var(--danger-bg); border-color: #f0cac7; color: #82201a; }
.note-ok     { background: var(--ok-bg);     border-color: #c2e0cd; color: #0f4d20; }

/* -------------------------------------------------------------- progress - */

.steps { display: flex; gap: 5px; margin: 16px 0 8px; }
.steps i { flex: 1; height: 7px; border-radius: 999px; background: var(--line-soft);
           transition: background .4s var(--ease); }
.steps i.done { background: var(--brand); }
.steps i.now  { background: var(--gold); }

/* The seven clearances, as a list a person can scan in one pass. */
.clearances { display: grid; gap: 9px; }
@media (min-width: 620px) { .clearances { grid-template-columns: 1fr 1fr; } }
.clearance {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
}
.clearance.is-done { background: var(--brand-wash); border-color: #c2e0cd; }

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

table.data { width: 100%; border-collapse: collapse; font-size: .96rem; }
table.data th, table.data td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line-soft);
}
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
                color: var(--ink-3); font-weight: 700; }
table.data td.num, table.data th.num { text-align: right;
                                       font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch;
                margin: 0 -22px; padding: 0 22px; }

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

.empty { text-align: center; padding: 52px 24px; }
.empty .art { width: 68px; height: 68px; margin: 0 auto 18px; color: var(--brand-soft);
              background: var(--brand-tint); border-radius: 20px;
              display: grid; place-items: center; }
.empty .art svg { width: 32px; height: 32px; }
.empty h3 { color: var(--ink); font-size: 1.2rem; }
.empty p  { color: var(--ink-3); margin-left: auto; margin-right: auto; }

.skeleton { background: linear-gradient(90deg, var(--line-soft) 25%,
            #f6f2e6 37%, var(--line-soft) 63%);
            background-size: 400% 100%; animation: sk 1.3s ease infinite;
            border-radius: var(--r-sm); }
@keyframes sk { 0% { background-position: 100% 50%; }
                100% { background-position: 0 50%; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
           overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

a:focus-visible, button:focus-visible, [tabindex]:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--brand-soft); outline-offset: 2px; border-radius: 6px;
}

/* --------------------------------------------------------------- motion - */
/* One authored moment: content arrives from an already-visible default, so a
   failed script or a reduced-motion setting leaves a readable page. */

@keyframes rise { from { opacity: 0; transform: translateY(10px); }
                  to   { opacity: 1; transform: none; } }
.rise { animation: rise .5s var(--ease) both; }
.rise-1 { animation-delay: .04s; }
.rise-2 { animation-delay: .08s; }
.rise-3 { animation-delay: .12s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------ sign-in --- */

.auth { min-height: 100vh; min-height: 100dvh; display: grid; }
@media (min-width: 920px) { .auth { grid-template-columns: 1.02fr .98fr; } }

.auth-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(158deg, var(--brand-deep) 0%, var(--brand) 58%, #1d8038 100%);
  color: #fff; padding: 56px 44px; display: flex; flex-direction: column;
  justify-content: center;
}
/* A single quiet shape from the brand, not a texture pattern. */
.auth-hero::after {
  content: ""; position: absolute; right: -120px; bottom: -140px;
  width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero h1 { color: #fff; max-width: 15ch; margin-bottom: .5em; }
.auth-hero p  { color: rgba(255,255,255,.86); max-width: 44ch; font-size: 1.06rem; }
.auth-hero .mark {
  width: 56px; height: 56px; border-radius: 16px; background: var(--gold);
  color: var(--brand-deep); display: grid; place-items: center;
  font: 700 20px/1 Lexend; margin-bottom: 26px;
}
.auth-hero ul { list-style: none; padding: 0; margin: 30px 0 0; }
.auth-hero li { display: flex; gap: 12px; align-items: flex-start;
                margin-bottom: 14px; color: rgba(255,255,255,.93); }
.auth-hero li svg { width: 21px; height: 21px; flex: 0 0 auto; margin-top: 3px;
                    color: var(--gold); }

.auth-panel { display: flex; align-items: center; justify-content: center;
              padding: 44px 24px; background: var(--surface); }
.auth-panel .inner { width: 100%; max-width: 372px; }

@media (max-width: 919px) {
  .auth-hero { padding: 34px 22px 30px; }
  .auth-hero p { font-size: 1rem; }
  .auth-hero ul { display: none; }
  .auth-hero .mark { width: 46px; height: 46px; margin-bottom: 18px; font-size: 17px; }
}

/* ------------------------------------------------- sticky form actions --- */
/* On a phone the primary action must not be below a 50-field form's fold. */

.actionbar {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 14px 0 max(14px, env(safe-area-inset-bottom));
  margin: 24px -22px -22px; padding-left: 22px; padding-right: 22px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  border-radius: 0 0 var(--r) var(--r);
}
.actionbar .btn { flex: 1 1 auto; }
@media (min-width: 640px) { .actionbar .btn { flex: 0 0 auto; } }

.env-badge {
  position: fixed; right: 14px; bottom: 14px; z-index: 99;
  box-shadow: var(--lift);
}
