/* CertBinder — clean, calm, product UI */
:root {
  --ink: #1c2a33;
  --bg: #f6f8fa;
  --card: #ffffff;
  --line: #dde5ea;
  --muted: #5d7280;
  --accent: #0b6e6e;
  --accent-dark: #085252;
  --good: #1a7f4b;
  --good-bg: #e7f5ec;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --bad: #b3261e;
  --bad-bg: #fdecea;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap { max-width: 960px; margin-inline: auto; padding-inline: 1.2rem; width: 100%; }

main.wrap { flex: 1; padding-block: 2rem 3rem; }

a { color: var(--accent); }

h1 { font-size: 1.6rem; margin-bottom: 1rem; }
h2 { font-size: 1.15rem; margin-bottom: 0.7rem; }
section { margin-block: 2rem; }

.lead { color: var(--muted); margin-bottom: 1rem; }
.muted { color: var(--muted); font-weight: normal; font-size: 0.9em; }
.note { color: var(--muted); font-size: 0.9rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.9rem; margin-block: 1rem; }

/* top bar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.bar-row { display: flex; align-items: center; justify-content: space-between; min-height: 3.4rem; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--accent-dark); text-decoration: none; }
.mainnav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.mainnav a { color: var(--ink); text-decoration: none; font-size: 0.95rem; }
.mainnav a:hover { color: var(--accent); }
.btn-add { border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.8rem; background: var(--bg); }

/* buttons and forms */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-dark); }

.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.92rem; padding: 0; text-decoration: underline; }
.linklike.danger { color: var(--bad); }
.inline-form { display: inline; }

.stdform, .authbox form { display: flex; flex-direction: column; gap: 0.9rem; max-width: 640px; }
.formrow { display: flex; gap: 1rem; flex-wrap: wrap; }
.formrow label { flex: 1; min-width: 160px; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.5rem 0.7rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.customfields { border: 1px dashed var(--line); border-radius: 8px; padding: 0.9rem; }
.customfields legend { font-size: 0.85rem; color: var(--muted); padding-inline: 0.4rem; }

/* auth */
.authbox { max-width: 420px; margin: 3rem auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2rem; }
.authbox .btn { align-self: flex-start; }
.authalt { margin-top: 1.2rem; font-size: 0.92rem; color: var(--muted); }

/* flash + banners */
.flash { border-radius: 8px; padding: 0.7rem 0.9rem; margin-bottom: 1rem; font-size: 0.95rem; }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-good { background: var(--good-bg); color: var(--good); }
.flashbar { margin-top: 0; }

.banner { border-radius: 10px; padding: 1rem 1.2rem; margin-block: 1.2rem; border: 1px solid var(--line); background: var(--card); }
.banner ul { margin-left: 1.1rem; }
.banner-good { background: var(--good-bg); border-color: #bfe5cd; color: var(--good); }
.banner-action { background: var(--warn-bg); border-color: #eedaa1; color: var(--warn); }
.banner-neutral { background: var(--card); }

/* dashboard cards */
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: var(--ink);
}
.card:hover { border-color: var(--accent); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }
.card h3 { font-size: 1.02rem; }
.card-title { color: var(--ink); text-decoration: none; }
.card-title:hover { color: var(--accent); text-decoration: underline; }
.card-sub { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }
.card-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.8rem; flex-wrap: wrap; }
.cardbtn { font-size: 0.8rem; font-weight: 600; color: var(--accent); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.7rem; background: var(--bg); cursor: pointer; }
.cardbtn:hover { border-color: var(--accent); }
.cardbtn-danger { color: var(--bad); }
.cardbtn-danger:hover { border-color: var(--bad); }

/* action tiles */
.actiongrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-block: 1.2rem 1.6rem; }
.statuszone { margin-top: 2.2rem; }

/* add-card tile */
.card-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; border-style: dashed; text-decoration: none; color: var(--accent); font-weight: 600; min-height: 9rem; text-align: center; }
.card-add:hover { background: var(--card); }
.card-add-plus { font-size: 1.8rem; line-height: 1; }
.card-add .card-sub { font-weight: 400; }

/* role tiles */
.rolegrid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.role-card { text-decoration: none; }
.role-selected { border-color: var(--accent); border-width: 2px; padding: calc(1.1rem - 1px) calc(1.2rem - 1px); }
.role-add { min-height: 6.5rem; }
.roledetail { border-top: 1px solid var(--line); padding-top: 1.4rem; }
.removerole { display: block; margin-top: 1.2rem; }
.rolepick { display: flex; flex-direction: column; flex: 1; }

/* recommendations */
.recommend { margin-top: 2rem; }
.recommendlist { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.recommendlist li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 1rem; display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }

.chip { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; border-radius: 999px; padding: 0.15rem 0.6rem; white-space: nowrap; }
.chip-ok { background: var(--good-bg); color: var(--good); }
.chip-due_soon { background: var(--warn-bg); color: var(--warn); }
.chip-action { background: var(--warn-bg); color: var(--warn); }
.chip-expired { background: var(--bad-bg); color: var(--bad); }

/* progress */
.progress { background: var(--line); border-radius: 999px; height: 8px; overflow: hidden; margin-top: 0.6rem; flex: 1; }
.progress-fill { background: var(--accent); height: 100%; border-radius: 999px; }
.progressblock { display: flex; flex-direction: column; gap: 0.6rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.2rem; }
.progressrow { display: grid; grid-template-columns: 180px 1fr 110px; gap: 0.9rem; align-items: center; font-size: 0.9rem; }
.progressrow .progress { margin-top: 0; }
.progressrow span:last-child { text-align: right; color: var(--muted); }
@media (max-width: 620px) { .progressrow { grid-template-columns: 1fr; gap: 0.25rem; } .progressrow span:last-child { text-align: left; } }

.p0{width:0}.p5{width:5%}.p10{width:10%}.p15{width:15%}.p20{width:20%}
.p25{width:25%}.p30{width:30%}.p35{width:35%}.p40{width:40%}.p45{width:45%}
.p50{width:50%}.p55{width:55%}.p60{width:60%}.p65{width:65%}.p70{width:70%}
.p75{width:75%}.p80{width:80%}.p85{width:85%}.p90{width:90%}.p95{width:95%}
.p100{width:100%}

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); }
.table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--bg); }
.table tr:last-child td { border-bottom: none; }

.doclist { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.detail-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; flex-wrap: wrap; }
.dangerzone { border-top: 1px solid var(--line); padding-top: 1.2rem; }
.dangerstack { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; }
.doc-actions { white-space: nowrap; }
.doc-actions .inline-form { margin-left: 0.6rem; }
.replace-details { display: inline-block; }
.replace-details summary { list-style: none; cursor: pointer; }
.replace-details summary::-webkit-details-marker { display: none; }
.replace-form { display: flex; gap: 0.5rem; margin-top: 0.4rem; align-items: center; }
.replace-form input[type="file"] { font-size: 0.8rem; max-width: 220px; }

.foot { border-top: 1px solid var(--line); padding-block: 1rem; color: var(--muted); font-size: 0.85rem; background: var(--card); }

/* pricing */
.pricegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.pricecard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem; display: flex; flex-direction: column; gap: 0.6rem; }
.pricecard-current { border-color: var(--accent); }
.price-line { font-size: 1.3rem; font-weight: 700; }
.price-line .muted { font-size: 0.85rem; font-weight: 400; }
.pricefeatures { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.pricefeatures li::before { content: "✓ "; color: var(--good); }
.btn-ghostlike { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn-ghostlike:hover { background: var(--line); }

/* tabs */
.tabrow { display: flex; gap: 0.4rem; margin-block: 1rem 1.4rem; border-bottom: 1px solid var(--line); }
.tab { padding: 0.45rem 1rem; border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0; text-decoration: none; color: var(--muted); background: var(--bg); font-size: 0.92rem; }
.tab-active { background: var(--card); color: var(--ink); font-weight: 600; border-color: var(--line); position: relative; top: 1px; }

/* documents: role subtabs + view eye */
.subtabs { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: -0.6rem 0 1.2rem; }
.subtab { font-size: 0.82rem; font-weight: 600; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.7rem; background: var(--card); }
.subtab-on { color: var(--accent); border-color: var(--accent); }
.eyelink { color: var(--muted); margin-right: 0.45rem; vertical-align: -3px; display: inline-block; }
.eyelink:hover { color: var(--accent); }

/* overall status */
.overall { border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 0.9rem 1.2rem; margin-bottom: 0.8rem; }
.overall-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.overall ul { margin: 0.4rem 0 0 1.1rem; font-size: 0.88rem; color: var(--muted); }
.overall-not_certified { border-color: #f0b9b5; }
.overall-attention { border-color: #eedaa1; }
.archived-link { margin-top: 1.4rem; }

/* autofill */
.autofillbox { border: 1px dashed var(--line); border-radius: 10px; padding: 1rem 1.2rem; background: var(--card); margin-bottom: 1.6rem; }
.autofillbox h2 { margin-bottom: 0.2rem; }

/* landing */
.hero-landing { padding-block: 2.5rem 1rem; max-width: 42rem; }
.hero-landing h1 { font-size: 2.1rem; line-height: 1.2; }
.steps-landing { max-width: 42rem; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.7rem; }
.steps-landing li::marker { color: var(--accent); font-weight: 700; }

/* export */
.exportlist { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; background: var(--card); }
.exportlist legend { font-size: 0.85rem; color: var(--muted); padding-inline: 0.4rem; }
.checkrow { flex-direction: row; align-items: baseline; gap: 0.6rem; font-size: 0.95rem; color: var(--ink); }
.checkrow input { accent-color: var(--accent); }
.checkrow .muted { display: block; }

/* chat */
.chatlog { display: flex; flex-direction: column; gap: 0.6rem; margin-block: 1.2rem; }
.bubble { max-width: 46rem; padding: 0.7rem 1rem; border-radius: 12px; white-space: pre-wrap; font-size: 0.95rem; }
.bubble-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble-assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble-md { white-space: normal; }
.bubble-md p, .bubble-md ul, .bubble-md ol { margin: 0 0 0.55rem; }
.bubble-md p:last-child, .bubble-md ul:last-child, .bubble-md ol:last-child { margin-bottom: 0; }
.bubble-md ul, .bubble-md ol { padding-left: 1.2rem; }
.bubble-md li { margin-bottom: 0.2rem; }
.bubble-md code { font-size: 0.9em; }
.bubble-typing { display: inline-flex; gap: 0.35rem; align-items: center; min-height: 2.2rem; }
.bubble-typing .dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; opacity: 0.3; animation: typing-blink 1.2s infinite; }
.bubble-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.bubble-typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 0.9; } }
@media (prefers-reduced-motion: reduce) { .bubble-typing .dot { animation: none; opacity: 0.6; } }
.chatform { display: flex; gap: 0.6rem; }
.chatform input[type="text"] { flex: 1; }


.sublink { font-size: 0.8rem; font-weight: 400; margin-left: 0.6rem; }
.detail-actions { margin-block: 0.6rem 1rem; }

/* delete confirm */
.confirm-details { display: inline-block; }
.confirm-details summary { list-style: none; cursor: pointer; }
.confirm-details summary::-webkit-details-marker { display: none; }
.confirm-form { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; }
.btn-danger-solid { background: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: #8c1d16; }

/* first-run checklist */
.checklist { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.checklist li { display: flex; gap: 0.7rem; align-items: baseline; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 1rem; }
.check-done { color: var(--good); font-weight: 700; }
.check-todo { color: var(--muted); font-weight: 700; }
.checklist .done-label { color: var(--muted); text-decoration: line-through; }

/* mobile nav */
@media (max-width: 700px) {
  .bar-row { flex-direction: column; align-items: flex-start; padding-block: 0.6rem; gap: 0.5rem; }
  .mainnav { gap: 0.7rem 0.9rem; font-size: 0.9rem; }
  .doc-actions { white-space: normal; }
}

/* dark mode: system preference (unless forced light) or forced dark */
html { color-scheme: light dark; }
html.theme-light { color-scheme: light; }
html.theme-dark { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  html:not(.theme-light) {
    --ink: #e8eff3;
    --bg: #10181d;
    --card: #1b2630;
    --line: #35454f;
    --muted: #a3b7c1;
    --accent: #4ecac4;
    --accent-dark: #74d8d3;
    --good: #74dba7;
    --good-bg: #17402d;
    --warn: #f0c674;
    --warn-bg: #453816;
    --bad: #f79087;
    --bad-bg: #48211d;
  }
  html:not(.theme-light) .btn,   html:not(.theme-light) .btn-solid { color: #06211f; }
  html:not(.theme-light) .btn-danger-solid { background: var(--bad); color: #2b0b08; }
  html:not(.theme-light) .bubble-user { color: #06211f; }
  html:not(.theme-light) .banner-good { border-color: #2a6e49; }
  html:not(.theme-light) .banner-action { border-color: #7d6a26; }
  html:not(.theme-light) .overall-not_certified { border-color: #7d332d; }
  html:not(.theme-light) .overall-attention { border-color: #7d6a26; }
  html:not(.theme-light) .brand { color: var(--accent); }
  html:not(.theme-light) .tab { color: var(--muted); }
  html:not(.theme-light) .tab-active { color: var(--ink); }
  html:not(.theme-light) .cardbtn { background: var(--card); }
  html:not(.theme-light) .btn-ghostlike { background: var(--card); color: var(--ink); }
}
html.theme-dark {
    --ink: #e8eff3;
    --bg: #10181d;
    --card: #1b2630;
    --line: #35454f;
    --muted: #a3b7c1;
    --accent: #4ecac4;
    --accent-dark: #74d8d3;
    --good: #74dba7;
    --good-bg: #17402d;
    --warn: #f0c674;
    --warn-bg: #453816;
    --bad: #f79087;
    --bad-bg: #48211d;
  }
html.theme-dark .btn, html.theme-dark .btn-solid { color: #06211f; }
html.theme-dark .btn-danger-solid { background: var(--bad); color: #2b0b08; }
html.theme-dark .bubble-user { color: #06211f; }
html.theme-dark .banner-good { border-color: #2a6e49; }
html.theme-dark .banner-action { border-color: #7d6a26; }
html.theme-dark .overall-not_certified { border-color: #7d332d; }
html.theme-dark .overall-attention { border-color: #7d6a26; }
html.theme-dark .brand { color: var(--accent); }
html.theme-dark .tab { color: var(--muted); }
html.theme-dark .tab-active { color: var(--ink); }
html.theme-dark .cardbtn { background: var(--card); }
html.theme-dark .btn-ghostlike { background: var(--card); color: var(--ink); }

/* theme toggle */
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.themetoggle { display: flex; gap: 0.35rem; align-items: center; }
.themebtn { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.78rem; color: var(--muted); cursor: pointer; }
.themebtn-on { border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* print: the status sheet */
@media print {
  .topbar, .foot, .actiongrid, .card-actions, .recommend, .replace-details,
  .confirm-details, .archived-link, .flashbar, form, .banner { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .overall { border-color: #999; break-inside: avoid; }
  .statuszone { margin-top: 0; }
  a { color: #000; text-decoration: none; }
}
