/* ==========================================================================
   Website Content Portal
   One stylesheet, no build step, no framework.
   ========================================================================== */

:root {
  --ink:        #1a1d21;
  --ink-2:      #4a5158;
  --ink-3:      #6b7480;
  --line:       #e2e6ea;
  --line-2:     #cdd4db;
  --bg:         #f5f7f9;
  --panel:      #ffffff;
  --brand:      #1f6feb;
  --brand-dark: #1a5ec4;
  --brand-tint: #eaf2fe;
  --ok:         #1a7f4b;
  --ok-tint:    #e6f5ec;
  --warn:       #9a6200;
  --warn-tint:  #fdf3e0;
  --danger:     #c02626;
  --danger-tint:#fdeaea;
  --radius:     8px;
  --radius-sm:  5px;
  --shadow:     0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:       ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .9em; background: #eef1f4; padding: .1em .35em; border-radius: 3px; }
pre  { font-family: var(--mono); font-size: .8rem; background: #eef1f4; padding: .75rem; border-radius: var(--radius-sm); overflow-x: auto; }

.muted     { color: var(--ink-3); }
.small     { font-size: .8125rem; }
.nowrap    { white-space: nowrap; }
.right     { text-align: right; }
.center    { text-align: center; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt1 { margin-top: .5rem; } .mb1 { margin-bottom: .5rem; }
.mt2 { margin-top: 1rem; }  .mb2 { margin-bottom: 1rem; }
.mt3 { margin-top: 1.5rem; }
.hide { display: none !important; }

/* ---------------------------------------------------------------- shell -- */

.topbar {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 52px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 650;
  color: #fff;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--brand);
  display: grid; place-items: center;
  font-size: .7rem; font-weight: 700;
}
.topnav { display: flex; gap: .25rem; margin-left: auto; align-items: center; flex-wrap: wrap; }
.topnav a {
  color: #c6ccd4;
  padding: .375rem .625rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
}
.topnav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.topnav a.active { background: rgba(255,255,255,.14); color: #fff; }
.topnav .sep { width: 1px; height: 20px; background: rgba(255,255,255,.18); margin: 0 .375rem; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.wrap-narrow { max-width: 760px; }

/* ------------------------------------------------------------ page head -- */

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-head .grow { flex: 1 1 320px; min-width: 0; }
.page-head h1 { margin-bottom: .25rem; }

.crumbs { font-size: .8125rem; color: var(--ink-3); margin-bottom: .375rem; }
.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--brand); }
.crumbs span { margin: 0 .375rem; opacity: .5; }

/* --------------------------------------------------------------- panels -- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.panel-head {
  padding: .875rem 1.125rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head .grow { flex: 1 1 auto; }
.panel-body { padding: 1.125rem; }
.panel-body.tight { padding: .75rem 1.125rem; }
.panel-foot {
  padding: .75rem 1.125rem;
  border-top: 1px solid var(--line);
  background: #fafbfc;
  border-radius: 0 0 var(--radius) var(--radius);
}

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------------------------------------------------------------- stats -- */

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow);
}
.stat .n { font-size: 1.75rem; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }
.stat .k { font-size: .8125rem; color: var(--ink-3); margin-top: .25rem; }
.stat.alert .n { color: var(--danger); }

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

.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  text-align: left;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
  font-weight: 600;
  padding: .625rem 1.125rem;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  white-space: nowrap;
}
.table td {
  padding: .75rem 1.125rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.empty {
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--ink-3);
}
.empty p { margin-bottom: .75rem; }

/* ------------------------------------------------------------- controls -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .5rem .875rem;
  font: inherit;
  font-size: .875rem;
  font-weight: 550;
  line-height: 1.2;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: #f6f8fa; text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: #fff; border-color: #eebcbc; color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef1f4; }
.btn-sm { padding: .3125rem .5625rem; font-size: .8125rem; }
.btn-xs { padding: .1875rem .375rem; font-size: .75rem; line-height: 1; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

label { display: block; margin-bottom: .875rem; font-size: .8125rem; font-weight: 600; color: var(--ink-2); }
label.inline { display: flex; align-items: flex-start; gap: .5rem; font-weight: 500; }
label.inline input { width: auto; margin-top: .15rem; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=date], input[type=tel], input[type=search],
select, textarea {
  display: block;
  width: 100%;
  margin-top: .3125rem;
  padding: .5rem .625rem;
  font: inherit;
  font-size: .875rem;
  font-weight: 400;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
input[readonly], textarea[readonly], input:disabled, textarea:disabled, select:disabled {
  background: #f3f5f7; color: var(--ink-2); cursor: default;
}
.hint { display: block; margin-top: .3125rem; font-size: .75rem; font-weight: 400; color: var(--ink-3); }

.field-row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

fieldset { border: 0; padding: 0; margin: 0 0 1rem; }

/* --------------------------------------------------------------- badges -- */

.badge {
  display: inline-block;
  padding: .1875rem .5rem;
  border-radius: 100px;
  font-size: .6875rem;
  font-weight: 650;
  letter-spacing: .02em;
  text-transform: uppercase;
  background: #eef1f4;
  color: var(--ink-2);
  white-space: nowrap;
}
.badge-draft       { background: #eef1f4; color: var(--ink-2); }
.badge-with_client { background: var(--warn-tint); color: var(--warn); }
.badge-in_review   { background: var(--brand-tint); color: var(--brand-dark); }
.badge-approved    { background: var(--ok-tint); color: var(--ok); }
.badge-active      { background: var(--ok-tint); color: var(--ok); }
.badge-on_hold     { background: var(--warn-tint); color: var(--warn); }
.badge-complete    { background: var(--brand-tint); color: var(--brand-dark); }
.badge-archived    { background: #eef1f4; color: var(--ink-3); }
.badge-todo        { background: #eef1f4; color: var(--ink-2); }
.badge-in_progress { background: var(--brand-tint); color: var(--brand-dark); }
.badge-blocked     { background: var(--danger-tint); color: var(--danger); }
.badge-done        { background: var(--ok-tint); color: var(--ok); }
.badge-overdue     { background: var(--danger-tint); color: var(--danger); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: .6875rem;
  font-weight: 700;
  flex: none;
}
.avatar.gray { background: #eef1f4; color: var(--ink-3); }
.who { display: inline-flex; align-items: center; gap: .375rem; }

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

.bar {
  height: 6px;
  background: #e8ecf0;
  border-radius: 100px;
  overflow: hidden;
  min-width: 70px;
}
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 100px; }
.bar.full > i { background: var(--ok); }
.progress-line { display: flex; align-items: center; gap: .625rem; }
.progress-line .pct { font-size: .75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 62px; }

/* --------------------------------------------------------------- alerts -- */

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 1rem;
  font-size: .875rem;
}
.alert p:last-child { margin-bottom: 0; }
.alert-ok    { background: var(--ok-tint); border-color: #b9e2c9; color: #14603a; }
.alert-error { background: var(--danger-tint); border-color: #f2c2c2; color: #8f1d1d; }
.alert-info  { background: var(--brand-tint); border-color: #c3daf9; color: #14448f; }
.alert-warn  { background: var(--warn-tint); border-color: #f0dcb4; color: #7a4e00; }

.flash-stack { position: sticky; top: 60px; z-index: 40; }

/* ----------------------------------------------------------------- tabs -- */

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.tabs a {
  padding: .625rem .875rem;
  font-size: .875rem;
  font-weight: 550;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* --------------------------------------------------------------- fields -- */

.section-block { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.25rem; background: var(--panel); box-shadow: var(--shadow); }
.section-head {
  padding: .875rem 1.125rem;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.section-head h3 { margin: 0; font-size: .9375rem; }
.section-head .grow { flex: 1 1 auto; }
.section-desc { font-size: .8125rem; color: var(--ink-3); margin: .25rem 0 0; width: 100%; }

.fld { padding: 1.125rem; border-bottom: 1px solid var(--line); }
.fld:last-child { border-bottom: 0; }
.fld-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .125rem; }
.fld-label { font-weight: 600; font-size: .875rem; }
.fld-help { font-size: .8125rem; color: var(--ink-3); margin: .125rem 0 .625rem; }
.fld-meta { font-size: .75rem; color: var(--ink-3); margin-top: .375rem; display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.fld.locked { background: #fbfcfd; }
.req { color: var(--danger); font-weight: 700; }

.counter { font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 600; }
.counter.near { color: var(--warn); }

.note-box { margin-top: .625rem; padding: .625rem .75rem; background: #fffdf5; border: 1px dashed #e6d9b8; border-radius: var(--radius-sm); }
.note-box textarea { min-height: 48px; background: transparent; border-color: #e6d9b8; }

/* ------------------------------------------------------------- repeater -- */

.rep-table { width: 100%; border-collapse: collapse; font-size: .875rem; margin-top: .3125rem; }
.rep-table th {
  text-align: left; font-size: .75rem; font-weight: 600; color: var(--ink-3);
  padding: .375rem .5rem; border-bottom: 1px solid var(--line);
}
.rep-table td { padding: .3125rem .25rem; vertical-align: top; }
.rep-table td:first-child, .rep-table th:first-child { padding-left: 0; }
.rep-table input, .rep-table textarea { margin-top: 0; }
.rep-table textarea { min-height: 62px; }
.rep-del { color: var(--ink-3); }
.rep-del:hover { color: var(--danger); background: var(--danger-tint); }

/* --------------------------------------------------------------- upload -- */

.file-list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.file-list li {
  display: flex; align-items: center; gap: .5rem;
  padding: .375rem .5rem;
  background: #f6f8fa;
  border-radius: var(--radius-sm);
  font-size: .8125rem;
}
.file-list .fsize { color: var(--ink-3); font-size: .75rem; margin-left: auto; }
input[type=file] { font-size: .8125rem; margin-top: .3125rem; }

/* -------------------------------------------------------------- comments -- */

.comment { padding: .625rem .75rem; background: #f6f8fa; border-radius: var(--radius-sm); margin-top: .5rem; font-size: .8125rem; }
.comment.client { background: var(--brand-tint); }
.comment.resolved { opacity: .55; }
.comment-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem; }
.comment-head strong { font-size: .8125rem; }

/* ----------------------------------------------------------- share link -- */

.link-box {
  display: flex; gap: .5rem; align-items: center;
  background: #f6f8fa; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .375rem .375rem .375rem .625rem;
}
.link-box input {
  border: 0; background: transparent; margin: 0; padding: 0;
  font-family: var(--mono); font-size: .75rem; flex: 1 1 auto; min-width: 0;
}
.link-box input:focus { box-shadow: none; }

/* ----------------------------------------------------------------- auth -- */

.auth-body { display: grid; place-items: center; min-height: 100vh; background: var(--bg); padding: 1.25rem; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(16,24,40,.08);
  padding: 1.75rem;
}
.auth-card h1 { font-size: 1.25rem; margin-bottom: 1.25rem; }

/* --------------------------------------------------------- client portal -- */

.client-body { background: #f7f8fa; }
.client-top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.25rem;
}
.client-top-inner { max-width: 880px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.client-wrap { max-width: 880px; margin: 0 auto; padding: 1.75rem 1.25rem 5rem; }
.client-wrap h1 { font-size: 1.375rem; }

.client-intro {
  background: var(--brand-tint);
  border: 1px solid #c3daf9;
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  margin-bottom: 1.5rem;
}
.client-intro p:last-child { margin-bottom: 0; }

.page-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.125rem;
  border-bottom: 1px solid var(--line);
  color: inherit;
  flex-wrap: wrap;
}
.page-card:hover { background: #fafbfc; text-decoration: none; }
.page-card:last-child { border-bottom: 0; }
.page-card .grow { flex: 1 1 220px; min-width: 0; }
.page-card .pname { font-weight: 600; }

.sticky-save {
  position: sticky; bottom: 0;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  padding: .75rem 1.125rem;
  display: flex; gap: .75rem; align-items: center; flex-wrap: wrap;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 20;
}
.sticky-save .grow { flex: 1 1 auto; }

/* --------------------------------------------------------------- print -- */

@media print {
  .topbar, .btn, .tabs, .sticky-save, .no-print { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .panel, .section-block { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .wrap { max-width: none; padding: 0; }
}

/* -------------------------------------------------------------- mobile -- */

@media (max-width: 640px) {
  .wrap { padding: 1rem .875rem 3rem; }
  .table th, .table td { padding: .625rem .75rem; }
  .topbar-inner { gap: .5rem; padding: .5rem .875rem; }
  .topnav { margin-left: 0; width: 100%; }
  .panel-head, .panel-body, .fld { padding-left: .875rem; padding-right: .875rem; }
}
