/* =============================================================================
   Gahanian Law - Document Manager
   Calm, professional, deliberately unfashionable. Optimised for clarity over
   decoration: this is a tool people use daily with sensitive client files.
   ========================================================================== */

:root {
  --ink:          #1a2634;
  --ink-soft:     #4d5a6a;
  --ink-faint:    #7c8794;
  --paper:        #f7f6f3;
  --surface:      #ffffff;
  --surface-alt:  #fafaf8;
  --line:         #e2ddd5;
  --line-strong:  #cfc8bd;
  --accent:       #1e3a52;
  --accent-hover: #162c3f;
  --accent-soft:  #eaeff4;
  --success:      #2b6a4d;
  --success-soft: #e8f2ec;
  --warn:         #8a6212;
  --warn-soft:    #fbf2dd;
  --danger:       #96302f;
  --danger-soft:  #fbeceb;
  --radius:       6px;
  --radius-lg:    10px;
  --shadow:       0 1px 2px rgba(26, 38, 52, .06), 0 2px 8px rgba(26, 38, 52, .04);
  --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif:   Georgia, "Times New Roman", serif;
  --font-mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: 700; color: var(--ink); line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; font-family: var(--font); }
p  { margin: 0 0 .8rem; }
a  { color: var(--accent); }

/* --- masthead ------------------------------------------------------------ */
.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead-inner {
  max-width: 1120px; margin: 0 auto; padding: .7rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--radius); background: var(--accent);
  color: #fff; font-family: var(--font-serif); font-weight: 700; font-size: .95rem;
  display: grid; place-items: center; flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .92rem; }
.brand-text small { font-size: .75rem; color: var(--ink-faint); }

.nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav a {
  padding: .4rem .7rem; border-radius: var(--radius); text-decoration: none;
  color: var(--ink-soft); font-size: .9rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-alt); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.account { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.account-name { color: var(--ink-soft); text-decoration: none; }
.account-name:hover { color: var(--ink); text-decoration: underline; }
.link-button {
  background: none; border: none; padding: 0; font: inherit; font-size: .85rem;
  color: var(--ink-faint); cursor: pointer; text-decoration: underline;
}
.link-button:hover { color: var(--danger); }

/* --- layout -------------------------------------------------------------- */
.page { max-width: 1120px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.page-narrow { max-width: 640px; }
.page-centred { display: grid; place-items: center; min-height: 82vh; }

.footer {
  max-width: 1120px; margin: 0 auto; padding: 1rem 1.25rem 2rem;
  color: var(--ink-faint); font-size: .78rem; text-align: center;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.4rem; box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-tight { padding: 1rem 1.2rem; }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.card-head h2 { margin: 0; }
.subtle { color: var(--ink-faint); font-size: .85rem; }
.lead { color: var(--ink-soft); font-size: 1rem; }

/* --- steps --------------------------------------------------------------- */
.steps { display: flex; gap: .5rem; margin: 0 0 1.5rem; flex-wrap: wrap; }
.step {
  flex: 1 1 180px; padding: .7rem .9rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); display: flex;
  align-items: center; gap: .6rem; min-width: 0;
}
.step-number {
  width: 24px; height: 24px; border-radius: 50%; background: var(--surface-alt);
  border: 1px solid var(--line-strong); color: var(--ink-faint);
  display: grid; place-items: center; font-size: .8rem; font-weight: 600; flex: none;
}
.step-label { font-size: .88rem; color: var(--ink-faint); font-weight: 500; }
.step.current { border-color: var(--accent); background: var(--accent-soft); }
.step.current .step-number { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.current .step-label { color: var(--accent); font-weight: 600; }
.step.done .step-number { background: var(--success); border-color: var(--success); color: #fff; }
.step.done .step-label { color: var(--ink-soft); }

/* --- buttons ------------------------------------------------------------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .58rem 1.1rem; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-size: .92rem;
  font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.button:hover { background: var(--accent-hover); }
.button:disabled, .button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.button-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.button-secondary:hover { background: var(--surface-alt); }
.button-danger { background: var(--danger); }
.button-danger:hover { background: #7d2827; }
.button-large { padding: .78rem 1.5rem; font-size: 1rem; }
.button-block { width: 100%; }
.button-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* --- forms --------------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .3rem; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=search] {
  width: 100%; padding: .58rem .7rem; font: inherit; font-size: .95rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.field input:focus, .button:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.field-hint { font-size: .8rem; color: var(--ink-faint); margin-top: .25rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }

/* --- messages ------------------------------------------------------------ */
.messages { margin-bottom: 1.25rem; display: grid; gap: .5rem; }
.message {
  padding: .7rem .95rem; border-radius: var(--radius); font-size: .92rem;
  border: 1px solid; border-left-width: 3px;
}
.message-success { background: var(--success-soft); border-color: #bcdcca; border-left-color: var(--success); color: #1f4f3a; }
.message-error   { background: var(--danger-soft);  border-color: #eec9c7; border-left-color: var(--danger);  color: #7d2827; }
.message-info    { background: var(--accent-soft);  border-color: #cfdce6; border-left-color: var(--accent);  color: var(--accent); }
.message-warning { background: var(--warn-soft);    border-color: #e8d8a8; border-left-color: var(--warn);    color: var(--warn); }

.notice {
  padding: .85rem 1rem; border-radius: var(--radius); font-size: .9rem;
  background: var(--warn-soft); border: 1px solid #e8d8a8; color: var(--warn);
  margin-bottom: 1rem;
}
.notice-info { background: var(--accent-soft); border-color: #cfdce6; color: var(--accent); }

/* --- breadcrumbs --------------------------------------------------------- */
.breadcrumbs { font-size: .88rem; color: var(--ink-faint); margin-bottom: .9rem; word-break: break-word; }
.breadcrumbs a { color: var(--ink-soft); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; color: var(--accent); }
.breadcrumbs .sep { margin: 0 .4rem; color: var(--line-strong); }
.breadcrumbs .current { color: var(--ink); font-weight: 600; }

/* --- selected folder banner ---------------------------------------------- */
.folder-banner {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid #cfdce6;
  border-radius: var(--radius-lg); padding: 1rem 1.2rem; margin-bottom: 1.25rem;
}
.folder-banner .folder-icon { font-size: 1.5rem; line-height: 1; }
.folder-banner .folder-meta { min-width: 0; flex: 1; }
.folder-banner .folder-name { font-weight: 700; font-size: 1.05rem; color: var(--accent); word-break: break-word; }
.folder-banner .folder-path { font-size: .82rem; color: var(--ink-soft); word-break: break-word; }

/* --- lists / tables ------------------------------------------------------ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .65rem .85rem; text-align: left; vertical-align: top; }
thead th {
  background: var(--surface-alt); border-bottom: 1px solid var(--line);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-faint); font-weight: 700; white-space: nowrap;
}
tbody tr + tr td { border-top: 1px solid var(--line); }
tbody tr:hover { background: var(--surface-alt); }
td.numeric, th.numeric { text-align: right; white-space: nowrap; }
td.shrink, th.shrink { width: 1%; white-space: nowrap; }

.filename { font-family: var(--font-mono); font-size: .84rem; word-break: break-all; }
.filename-old { color: var(--ink-soft); }
.filename-new { color: var(--success); font-weight: 600; }
.arrow { color: var(--ink-faint); padding: 0 .5rem; }

.rename-pair { display: flex; align-items: baseline; gap: .35rem; flex-wrap: wrap; }

/* --- folder list --------------------------------------------------------- */
.folder-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.folder-list li + li { border-top: 1px solid var(--line); }
.folder-list a {
  display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem;
  text-decoration: none; color: var(--ink);
}
.folder-list a:hover { background: var(--accent-soft); }
.folder-list .icon { font-size: 1.1rem; flex: none; }
.folder-list .name { flex: 1; font-weight: 500; word-break: break-word; }
.folder-list .go { color: var(--ink-faint); font-size: .85rem; flex: none; }

/* --- status pills -------------------------------------------------------- */
.pill {
  display: inline-block; padding: .16rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  border: 1px solid;
}
.pill-ready        { background: var(--accent-soft);  color: var(--accent);  border-color: #cfdce6; }
.pill-applied      { background: var(--success-soft); color: var(--success); border-color: #bcdcca; }
.pill-needs_review { background: var(--warn-soft);    color: var(--warn);    border-color: #e8d8a8; }
.pill-failed,
.pill-conflict     { background: var(--danger-soft);  color: var(--danger);  border-color: #eec9c7; }
.pill-skipped,
.pill-excluded,
.pill-unsupported,
.pill-pending      { background: var(--surface-alt);  color: var(--ink-faint); border-color: var(--line-strong); }

/* --- empty state --------------------------------------------------------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-faint); }
.empty .empty-icon { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* --- summary stats ------------------------------------------------------- */
.stats { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat {
  flex: 1 1 140px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: .9rem 1rem;
}
.stat .stat-value { font-size: 1.5rem; font-weight: 700; font-family: var(--font-serif); line-height: 1.1; }
.stat .stat-label { font-size: .8rem; color: var(--ink-faint); margin-top: .15rem; }
.stat-ready  .stat-value { color: var(--accent); }
.stat-review .stat-value { color: var(--warn); }
.stat-done   .stat-value { color: var(--success); }
.stat-error  .stat-value { color: var(--danger); }

/* --- progress ------------------------------------------------------------ */
.progress-track { height: 8px; background: var(--surface-alt); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); width: 0%; transition: width .4s ease; }

/* --- naming rules -------------------------------------------------------- */
.rule { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); margin-bottom: .9rem; overflow: hidden; }
.rule-head { padding: .8rem 1.1rem; background: var(--surface-alt); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.rule-head h3 { margin: 0; font-size: .98rem; font-weight: 700; }
.rule-folder { font-size: .78rem; color: var(--ink-faint); }
.rule-body { padding: 1rem 1.1rem; }
.rule-body pre {
  margin: 0; font-family: var(--font-mono); font-size: .84rem; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; color: var(--ink-soft);
}
.rule-example { font-family: var(--font-mono); background: var(--surface-alt); padding: .15rem .4rem; border-radius: 3px; border: 1px solid var(--line); }

/* --- misc ---------------------------------------------------------------- */
.credential {
  font-family: var(--font-mono); font-size: 1rem; background: var(--surface-alt);
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: .7rem .9rem; word-break: break-all; user-select: all;
}
.divider { height: 1px; background: var(--line); border: 0; margin: 1.25rem 0; }
.checkbox-cell { width: 1%; }
.muted-row td { opacity: .62; }
.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;
}

@media (max-width: 720px) {
  .masthead-inner { gap: .75rem; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .account { margin-left: auto; }
  .page { padding: 1.25rem 1rem 2rem; }
  .steps { flex-direction: column; }
}
