/* ScribeSetu - accessible, mobile-first stylesheet */
:root {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --primary: #0b3d91;
  --primary-dark: #082c69;
  --accent: #0f766e;
  --warn: #92400e;
  --warn-bg: #fff4e0;
  --danger: #b00020;
  --danger-bg: #fdecee;
  --ok: #14532d;
  --ok-bg: #e6f6ec;
  --info-bg: #e8f0fe;
  --border: #c9d3e3;
  --focus: #ff9f1c;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(15, 30, 70, .08);
}
html { font-size: 18px; scroll-behavior: smooth; }
html[data-text="lg"] { font-size: 21px; }
html[data-text="xl"] { font-size: 25px; }
html[data-text="sm"] { font-size: 16px; }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  line-height: 1.6; -webkit-text-size-adjust: 100%;
}
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 1rem; }
.page { padding-top: 1.5rem; padding-bottom: 3rem; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.2em 0 .5em; color: #0a2a63; }
h1 { font-size: 2rem; margin-top: .4em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
ul, ol { padding-left: 1.3rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Focus - always clearly visible */
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
.skip-link {
  position: absolute; left: .5rem; top: -4rem; background: #000; color: #fff; padding: .8rem 1.2rem;
  z-index: 1000; border-radius: 0 0 8px 8px; font-weight: 700;
}
.skip-link:focus { top: 0; }

/* Accessibility bar */
.a11y-bar { background: #0a1f44; color: #fff; font-size: .85rem; }
.a11y-inner { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding-top: .35rem; padding-bottom: .35rem; }
.a11y-title { font-weight: 700; margin-right: .3rem; }
.a11y-btn {
  background: transparent; color: #fff; border: 2px solid #fff; border-radius: 6px; padding: .15rem .7rem;
  font: inherit; cursor: pointer; min-height: 36px;
}
.a11y-btn:hover, .a11y-btn[aria-pressed="true"] { background: #fff; color: #0a1f44; }

/* Header and navigation */
.site-header { background: var(--surface); border-bottom: 3px solid var(--primary); box-shadow: var(--shadow); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem; padding-top: .7rem; padding-bottom: .7rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-size: 1.5rem; font-weight: 800; color: var(--primary); text-decoration: none; }
.brand-mark { display: inline-flex; width: 2.2rem; height: 2.2rem; align-items: center; justify-content: center; background: var(--primary); color: #fff; border-radius: 50%; font-size: 1.2rem; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem .4rem; align-items: center; }
.main-nav a, .linklike {
  display: inline-block; padding: .5rem .8rem; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600;
  min-height: 44px; line-height: 1.6;
}
.main-nav a:hover, .linklike:hover { background: var(--info-bg); color: var(--primary-dark); }
.main-nav a[aria-current="page"] { background: var(--primary); color: #fff; }
.main-nav a.btn { color: #fff; }
.linklike { background: none; border: 0; cursor: pointer; font-family: inherit; font-size: 1rem; }
.inline-form { display: inline; margin: 0; }
.count { display: inline-block; min-width: 1.5rem; text-align: center; background: var(--danger); color: #fff; border-radius: 999px; font-size: .8rem; padding: 0 .4rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .6rem 1.3rem;
  background: var(--primary); color: #fff; border: 2px solid var(--primary); border-radius: 10px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-small { min-height: 40px; padding: .3rem .9rem; font-size: .95rem; }
.btn-large { min-height: 58px; font-size: 1.15rem; padding: .8rem 1.8rem; }
.btn-outline { background: #fff; color: var(--primary); }
.btn-outline:hover { background: var(--info-bg); color: var(--primary-dark); }
.btn-green { background: var(--accent); border-color: var(--accent); }
.btn-green:hover { background: #0b5a54; border-color: #0b5a54; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #82001a; border-color: #82001a; }
.btn-light { background: #fff; color: var(--primary-dark); border-color: #fff; }
.btn-light:hover { background: var(--info-bg); color: var(--primary-dark); }
.btn-row { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1rem 0; }
button[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* Flash messages */
.flash-wrap:empty { display: none; }
.flash { padding: .9rem 1.1rem; border-radius: var(--radius); border: 2px solid; margin-top: 1rem; font-weight: 600; }
.flash-success { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.flash-error { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.flash-info { background: var(--info-bg); border-color: var(--primary); color: var(--primary-dark); }
.flash-warning { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }

/* Cards and grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-accent { border-left: 6px solid var(--primary); }
.card-urgent { border-left: 6px solid var(--danger); }
.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }

/* Hero (home) */
.hero { background: linear-gradient(135deg, #0a2a63, #0b3d91 60%, #1259c3); color: #fff; padding: 3rem 0 3.5rem; }
.hero h1 { color: #fff; font-size: 2.3rem; max-width: 22ch; }
.hero p { font-size: 1.2rem; max-width: 55ch; }
.hero-cta { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); margin-top: 1.8rem; }
.cta-card { display: block; background: #fff; color: var(--text); border-radius: var(--radius); padding: 1.2rem; text-decoration: none; border: 3px solid transparent; }
.cta-card:hover { border-color: var(--focus); color: var(--text); }
.cta-card strong { display: block; font-size: 1.25rem; color: var(--primary); margin-bottom: .2rem; }
.cta-card span { color: var(--muted); font-size: .95rem; }
.cta-icon { font-size: 2rem; display: block; margin-bottom: .3rem; }
.section { padding: 2.5rem 0; }
.section-alt { background: #fff; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.steps { list-style: none; padding: 0; counter-reset: step; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.steps li { counter-increment: step; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; position: relative; }
.steps li::before {
  content: counter(step); display: inline-flex; width: 2.3rem; height: 2.3rem; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border-radius: 50%; font-weight: 800; margin-bottom: .6rem;
}
.stat { text-align: center; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat .num { display: block; font-size: 2.2rem; font-weight: 800; color: var(--primary); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .95rem; }

/* Forms */
form.stacked { max-width: 760px; }
.field { margin-bottom: 1.2rem; }
label, legend { display: block; font-weight: 700; margin-bottom: .3rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0 0 1.2rem; background: #fff; }
legend { padding: 0 .4rem; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; color: var(--text); background: #fff;
  border: 2px solid #6b7a99; border-radius: 8px;
}
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.hint { color: var(--muted); font-size: .92rem; margin: 0 0 .4rem; }
.req { color: var(--danger); font-weight: 600; font-size: .85rem; }
.opt { color: var(--muted); font-weight: 400; font-size: .85rem; }
.error-text { color: var(--danger); font-weight: 700; margin: 0 0 .4rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: .3rem .8rem; }
.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 400; padding: .35rem .2rem; min-height: 44px; cursor: pointer; }
.check input { width: 1.4rem; height: 1.4rem; margin-top: .15rem; flex: 0 0 auto; accent-color: var(--primary); }
.hp-field { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.voice-btn { margin-top: .35rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-top: 1.2rem; }
.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 170px; }

/* Tabs / pills */
.pills { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0 0 1.2rem; }
.pills a { display: inline-block; padding: .45rem 1rem; border: 2px solid var(--primary); border-radius: 999px; text-decoration: none; font-weight: 700; min-height: 44px; }
.pills a[aria-current="page"], .pills a:hover { background: var(--primary); color: #fff; }

/* Tables */
.table-wrap { overflow-x: auto; margin-bottom: 1.2rem; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; }
caption { text-align: left; font-weight: 700; padding: .8rem 1rem; }
th, td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #eaf0fb; font-size: .92rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* Badges */
.badge { display: inline-block; padding: .1rem .7rem; border-radius: 999px; font-size: .85rem; font-weight: 700; border: 2px solid; background: #fff; white-space: nowrap; }
.badge-open, .badge-pending, .badge-new, .badge-reviewing { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.badge-confirmed, .badge-accepted, .badge-verified, .badge-active, .badge-resolved, .badge-handled { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.badge-completed { color: var(--primary-dark); border-color: var(--primary); background: var(--info-bg); }
.badge-cancelled, .badge-expired, .badge-declined, .badge-withdrawn, .badge-rejected, .badge-suspended, .badge-dismissed { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.badge-urgent { color: #fff; border-color: var(--danger); background: var(--danger); }
.badge-match { color: var(--primary-dark); border-color: var(--primary); background: var(--info-bg); }

/* Detail lists */
dl.details { display: grid; grid-template-columns: minmax(130px, 220px) 1fr; gap: .5rem 1rem; margin: 0; }
dl.details dt { font-weight: 700; color: var(--muted); }
dl.details dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { dl.details { grid-template-columns: 1fr; gap: 0; } dl.details dt { margin-top: .6rem; } }

.item-list { list-style: none; padding: 0; margin: 0; }
.item-list > li { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.item-list > li:last-child { border-bottom: 0; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; justify-content: space-between; }
.item-head h3 { margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; color: var(--muted); font-size: .95rem; margin: .3rem 0; }

/* Chat */
.chat { max-height: 24rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; background: #f8fafe; margin-bottom: 1rem; }
.msg { max-width: 85%; padding: .6rem .9rem; border-radius: 12px; margin-bottom: .6rem; background: #fff; border: 1px solid var(--border); }
.msg.mine { margin-left: auto; background: var(--info-bg); border-color: #b9cdf5; }
.msg .who { font-size: .8rem; color: var(--muted); display: block; }

/* Pager */
.pager ul { list-style: none; display: flex; gap: .4rem; padding: 0; flex-wrap: wrap; }
.pager a, .pager .current { display: inline-block; min-width: 44px; min-height: 44px; padding: .5rem .8rem; border: 2px solid var(--primary); border-radius: 8px; text-align: center; text-decoration: none; font-weight: 700; }
.pager .current { background: var(--primary); color: #fff; }

details.faq { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .8rem; }
details.faq summary { cursor: pointer; padding: 1rem 1.2rem; font-weight: 700; min-height: 48px; }
details.faq div { padding: 0 1.2rem 1rem; }
details.inline summary { cursor: pointer; font-weight: 700; padding: .5rem 0; color: var(--primary); }

.notice { padding: 1rem 1.2rem; border-radius: var(--radius); border: 2px solid var(--warn); background: var(--warn-bg); color: #5b2c05; margin-bottom: 1.2rem; }
.notice-info { border-color: var(--primary); background: var(--info-bg); color: var(--primary-dark); }
.notice-ok { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.notice > :last-child { margin-bottom: 0; }

/* Footer */
.site-footer { background: #0a1f44; color: #e6edfb; padding-top: 2rem; }
.site-footer a { color: #fff; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: .4rem; }
.footer-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.footer-brand { font-size: 1.4rem; font-weight: 800; margin: 0 0 .3rem; color: #fff; }
.footer-head { font-weight: 700; margin-bottom: .5rem; color: #fff; }
.footer-bottom { border-top: 1px solid #2c4472; margin-top: 1.5rem; padding-top: 1rem; padding-bottom: 1rem; font-size: .9rem; }

/* Admin sub-navigation */
.admin-nav { background: #eaf0fb; border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem; margin-bottom: 1.5rem; }
.admin-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.admin-nav a { display: inline-block; padding: .4rem .9rem; border-radius: 8px; text-decoration: none; font-weight: 600; min-height: 40px; }
.admin-nav a:hover { background: #fff; }
.admin-nav a[aria-current="page"] { background: var(--primary); color: #fff; }

/* Certificate */
.certificate {
  background: #fff; border: 10px double #0b3d91; padding: 2.5rem 1.5rem; text-align: center; max-width: 900px; margin: 1rem auto;
}
.certificate h1 { font-size: 2.2rem; letter-spacing: .05em; text-transform: uppercase; margin-top: 0; }
.certificate .who { font-size: 2rem; font-weight: 800; color: var(--primary); margin: .6rem 0; }
.certificate .code { font-family: monospace; font-size: 1rem; margin-top: 1.5rem; }

/* High contrast mode */
html[data-contrast="high"] { --bg: #000; --surface: #000; --text: #fff; --muted: #f2f2f2; --primary: #ffe600; --primary-dark: #fff27a;
  --accent: #00e5ff; --border: #fff; --info-bg: #111; --ok-bg: #000; --warn-bg: #000; --danger-bg: #000; --ok: #7dff9b; --warn: #ffd27a; --danger: #ff8a8a; --focus: #00e5ff; }
html[data-contrast="high"] body { background: #000; color: #fff; }
html[data-contrast="high"] h1, html[data-contrast="high"] h2, html[data-contrast="high"] h3, html[data-contrast="high"] h4 { color: #ffe600; }
html[data-contrast="high"] a { color: #ffe600; }
html[data-contrast="high"] .site-header, html[data-contrast="high"] .card, html[data-contrast="high"] .steps li,
html[data-contrast="high"] .stat, html[data-contrast="high"] fieldset, html[data-contrast="high"] details.faq,
html[data-contrast="high"] .table-wrap, html[data-contrast="high"] .msg, html[data-contrast="high"] .chat,
html[data-contrast="high"] .section-alt, html[data-contrast="high"] .admin-nav { background: #000; border-color: #fff; }
html[data-contrast="high"] .btn { background: #ffe600; color: #000; border-color: #ffe600; }
html[data-contrast="high"] .btn:hover { background: #fff; color: #000; border-color: #fff; }
html[data-contrast="high"] .btn-outline { background: #000; color: #ffe600; border-color: #ffe600; }
html[data-contrast="high"] .btn-danger { background: #ff4d4d; border-color: #ff4d4d; color: #000; }
html[data-contrast="high"] .btn-light { background: #000; color: #ffe600; border-color: #ffe600; }
html[data-contrast="high"] .hero { background: #000; border-bottom: 3px solid #ffe600; }
html[data-contrast="high"] .cta-card { background: #000; color: #fff; border-color: #fff; }
html[data-contrast="high"] .cta-card strong { color: #ffe600; }
html[data-contrast="high"] .main-nav a { color: #fff; }
html[data-contrast="high"] .main-nav a[aria-current="page"], html[data-contrast="high"] .pills a[aria-current="page"],
html[data-contrast="high"] .admin-nav a[aria-current="page"] { background: #ffe600; color: #000; }
html[data-contrast="high"] .brand-mark { background: #ffe600; color: #000; }
html[data-contrast="high"] input, html[data-contrast="high"] select, html[data-contrast="high"] textarea { background: #000; color: #fff; border-color: #fff; }
html[data-contrast="high"] th { background: #222; color: #fff; }
html[data-contrast="high"] .site-footer, html[data-contrast="high"] .a11y-bar { background: #000; border-top: 2px solid #fff; }
html[data-contrast="high"] .badge { background: #000; }
html[data-contrast="high"] .count { background: #ff4d4d; color: #000; }
html[data-contrast="high"] .stat .num { color: #ffe600; }
html[data-contrast="high"] .msg.mine { background: #1a1a1a; }
html[data-contrast="high"] .notice { color: #fff; background: #000; }
html[data-contrast="high"] .certificate { background: #000; border-color: #ffe600; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }
@media (max-width: 640px) {
  h1 { font-size: 1.6rem; } .hero h1 { font-size: 1.8rem; }
  .main-nav ul { gap: .1rem; }
}
@media print {
  .a11y-bar, .site-header, .site-footer, .no-print, .skip-link, .admin-nav { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .certificate { border-color: #0b3d91 !important; background: #fff !important; color: #000 !important; }
  .certificate h1, .certificate .who { color: #0b3d91 !important; }
  .page { padding: 0; }
}
