/* Pavia BPLO resident portal — design system.
 *
 * The palette is Pavia BPLO's own, taken from the app residents already use:
 * a dark green wordmark on warm cream. Not invented, and deliberately not the
 * municipal seal's navy — the seal is the LGU's crest, the green is what people
 * recognise as this service.
 *
 * One file, no build step. Tokens live on :root so the LGU's real brand assets
 * can replace them in one edit.
 */

:root {
  /* Pavia BPLO's own colours, taken from the app residents already use:
   * lib/utilities/global.dart — DarkerGreenColor, logoColor, PrimaryColor,
   * WhiteColor, Primary3Color. Green wordmark on warm cream.
   *
   * NOT the municipal seal's navy. The seal is the LGU's crest; the green is
   * what people recognise as this service. */
  --brand:       #146b2b;   /* between logoColor and DarkerGreenColor */
  --brand-deep:  #0e5420;
  --brand-soft:  #28a745;   /* logoColor — links, focus */
  --brand-tint:  #e8f4ec;

  /* Warm neutrals from the app's cream background */
  --cream:       #fcf4e2;   /* WhiteColor */
  --cream-deep:  #ffe6b4;   /* PrimaryColor */
  --gold:        #d79d11;   /* Primary3Color */

  --ink:         #1d2419;
  --ink-2:       #4a5347;
  --ink-3:       #6e7a6b;
  --line:        #e3e2d6;
  --line-soft:   #efeee4;
  --bg:          #fcf4e2;
  --surface:     #ffffff;

  /* Status. Green already means "brand" here, so OK uses a deeper, distinct
   * green and never the brand tone — otherwise every card looks approved. */
  --danger:      #b3261e;
  --danger-bg:   #fdeceb;
  --warn:        #8a5d00;
  --warn-bg:     #fdf1d8;
  --ok:          #1a6b3c;
  --ok-bg:       #e2f1e8;
  --info:        #1f5673;
  --info-bg:     #e7f0f6;

  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 2px rgba(29,36,25,.06), 0 8px 24px rgba(29,36,25,.06);
  --shadow-lg:   0 2px 6px rgba(29,36,25,.08), 0 20px 48px rgba(29,36,25,.12);
  --maxw:        1080px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3 { font-family: Lexend, var(--sans, inherit); font-weight: 600;
             letter-spacing: -.01em; margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 1em; }
a  { color: var(--brand-soft); }

.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

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

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

.topbar {
  background: var(--brand); color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset;
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 62px; }
.topbar a { color: rgba(255,255,255,.86); text-decoration: none; }
.topbar a:hover { color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-family: Lexend;
         font-weight: 600; color: #fff !important; }
.brand img { width: 34px; height: 34px; border-radius: 50%; background: #fff; }
.brand small { display: block; font: 400 11px/1 "Source Sans 3";
               color: rgba(255,255,255,.7); letter-spacing: .04em;
               text-transform: uppercase; }
.topnav { margin-left: auto; display: flex; gap: 20px; align-items: center; }
.topnav .current { color: #fff; box-shadow: 0 2px 0 var(--gold); }

main { padding: 28px 0 72px; }

.grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .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: 12px; align-items: center;
          justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }

/* --- surfaces ----------------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card.pad-lg { padding: 28px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

.card-link { display: block; text-decoration: none; color: inherit;
             transition: box-shadow .15s, transform .15s, border-color .15s; }
.card-link:hover { box-shadow: var(--shadow-lg); border-color: var(--brand-soft);
                   transform: translateY(-1px); }

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

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

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 15px/1 "Source Sans 3"; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-deep); }
.btn-ghost { background: var(--surface); color: var(--brand);
             border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand-soft); }
.btn-quiet { background: transparent; color: var(--ink-3); padding: 8px 10px; }
.btn-quiet:hover:not(:disabled) { color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 14px; }

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

.field { display: block; margin-bottom: 16px; }
/* `.field` IS the <label>; the caption inside it is a <span>. Styling only
   `.field > label` missed it entirely, and the caption sat inline beside the
   control — invisible wherever the control happened to be full width. */
.field > span, .field > label, .label {
  display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px;
}
.field > span .muted, .field > label .muted { font-weight: 400; }
.field .hint { font-size: .85rem; color: var(--ink-3); margin: 4px 0 0; }

/* `input:not([type])` matters: an <input> with no type attribute IS a text
   input, but no [type=text] selector matches it. Half this form's fields omit
   it, and they rendered at their default inline width. */
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%; padding: 11px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(40,167,69,.18);
}
input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179,38,30,.14);
}
textarea { min-height: 96px; resize: vertical; }
.field-error { color: var(--danger); font-size: .85rem; margin: 5px 0 0; }

/* A checkbox beside its label. `.row` alone wraps the text onto its own line,
   because a long span with no flex-basis is sized by its content. */
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.check input[type=checkbox] { width: 18px; height: 18px; margin: 2px 0 0;
                              flex: 0 0 auto; accent-color: var(--brand); }
.check > span { flex: 1 1 auto; }

/* File inputs. The browser default is an unlabelled grey button that says
   nothing about what is wanted; the button text is restyled rather than hidden
   behind a fake control, so keyboard and screen-reader behaviour is untouched. */
input[type=file] {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink-3);
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
}
input[type=file]:hover { border-color: var(--brand-soft); }
input[type=file]:focus { outline: none; border-color: var(--brand-soft);
                         box-shadow: 0 0 0 3px rgba(40,167,69,.18); }
input[type=file]::file-selector-button {
  font: 600 14px/1 "Source Sans 3"; margin-right: 12px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
  background: var(--brand-tint); color: var(--brand-deep);
}
input[type=file]::file-selector-button:hover { background: #dbeee2; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius);
           padding: 16px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; font-size: .92rem; }

/* A 6-digit code or PIN. Big, spaced, tabular. */
.code-input {
  font: 600 26px/1 "Source Sans 3"; letter-spacing: .5em; text-align: center;
  padding: 14px 12px 14px 20px; font-variant-numeric: tabular-nums;
}

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

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.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-3); }

.note {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: .92rem;
  border: 1px solid transparent;
}
.note-info   { background: var(--info-bg);   border-color: #cfe0ee; color: #1d4362; }
.note-warn   { background: var(--warn-bg);   border-color: #f0dca5; color: #7a5200; }
.note-danger { background: var(--danger-bg); border-color: #f3c9c9; color: #8c1c1c; }
.note-ok     { background: var(--ok-bg);     border-color: #bfe4d0; color: #145f38; }
.note p:last-child { margin-bottom: 0; }

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

.steps { display: flex; gap: 4px; margin: 14px 0 6px; }
.steps i { flex: 1; height: 6px; border-radius: 999px; background: var(--line); }
.steps i.done { background: var(--brand); }
.steps i.now  { background: var(--gold); }
.steps i.off  { background: var(--line); }

.clearances { display: grid; gap: 8px; }
@media (min-width: 640px) { .clearances { grid-template-columns: 1fr 1fr; } }
.clearance { display: flex; align-items: center; justify-content: space-between;
             gap: 10px; padding: 10px 12px; border: 1px solid var(--line);
             border-radius: var(--radius-sm); background: var(--surface); }

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

table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { padding: 10px 12px; text-align: left;
                               border-bottom: 1px solid var(--line-soft); }
table.data th { font-size: .82rem; text-transform: uppercase;
                letter-spacing: .04em; color: var(--ink-3); font-weight: 600; }
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; }

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

.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink); }

.skeleton { background: linear-gradient(90deg, var(--line-soft) 25%,
            #f7f8fc 37%, var(--line-soft) 63%);
            background-size: 400% 100%; animation: sk 1.2s ease infinite;
            border-radius: var(--radius-sm); height: 1em; }
@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;
}

/* Visible focus for keyboard users on every interactive thing. */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(40,167,69,.5); outline-offset: 2px;
  border-radius: 4px;
}

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

.auth { min-height: 100vh; display: grid; }
@media (min-width: 900px) { .auth { grid-template-columns: 1.05fr .95fr; } }

.auth-hero {
  background: linear-gradient(155deg, var(--brand-deep), var(--brand) 60%, #1d8038);
  color: #fff; padding: 48px 40px; display: flex; flex-direction: column;
  justify-content: center;
}
.auth-hero h1 { color: #fff; font-size: 2rem; max-width: 14ch; }
.auth-hero p { color: rgba(255,255,255,.82); max-width: 46ch; }
.auth-hero .seal { width: 84px; height: 84px; border-radius: 50%;
                   background: #fff; padding: 6px; margin-bottom: 22px; }
.auth-hero ul { list-style: none; padding: 0; margin: 22px 0 0; }
.auth-hero li { padding-left: 26px; position: relative; margin-bottom: 10px;
                color: rgba(255,255,255,.9); }
.auth-hero li::before { content: ""; position: absolute; left: 0; top: .5em;
                        width: 12px; height: 12px; border-radius: 50%;
                        background: var(--gold); }

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

@media (max-width: 899px) {
  .auth-hero { padding: 32px 24px; }
  .auth-hero h1 { font-size: 1.6rem; }
  .auth-hero ul { display: none; }
}
