/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:      #1c2b3a;
  --navy-dark: #141f2b;
  --teal:      #0e7c7b;
  --teal-lt:   #e6f4f4;
  --amber-lt:  #fffbf0;
  --amber-bd:  #f5e7c0;
  --blue-lt:   #f0f5ff;
  --blue-bd:   #c8d8f8;
  --red:       #c0392b;
  --green:     #27ae60;
  --green-dk:  #1e8449;
  --gray-50:   #f8f9fa;
  --gray-100:  #f0f1f3;
  --gray-200:  #e2e4e8;
  --gray-400:  #9aa0ac;
  --gray-600:  #5a6170;
  --gray-800:  #2d3340;
  --text:      #1a1f2b;
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono:      'SF Mono', 'Fira Code', Consolas, monospace;
  --radius:    6px;
  --shadow:    0 1px 4px rgba(0,0,0,.1);
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--gray-50);
  min-height: 100vh;
}

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy-dark);
}

.login-card {
  background: #fff;
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 360px;
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
}

.login-brand {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  margin-bottom: 1.2rem;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .2rem;
}

.login-subtitle {
  color: var(--gray-600);
  font-size: .85rem;
  margin-bottom: 1.6rem;
}

.login-error {
  background: #fef0f0;
  border: 1px solid #f0c0c0;
  color: var(--red);
  padding: .6rem .8rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font: inherit;
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,124,123,.1);
}

.form-group--wide { flex: 1; }

.form-group--check {
  display: flex;
  align-items: flex-end;
  padding-bottom: .2rem;
}

.form-group--check label {
  display: flex;
  align-items: center;
  gap: .4rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: .9rem;
  font-weight: normal;
  color: var(--text);
}

.btn-login {
  width: 100%;
  padding: .65rem;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-top: .4rem;
}

.btn-login:hover { background: var(--green-dk); }

/* ── Brand ────────────────────────────────────────────────────────────────── */
.brand-link {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  text-decoration: none;
}
.brand-link:hover .brand-mumbrella { color: var(--teal-lt, #e6f4f4); }

.brand-mumbrella {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .02em;
}

.brand-tools {
  font-size: .75rem;
  font-weight: 500;
  color: rgba(255,255,255,.6);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.brand-sep {
  color: rgba(255,255,255,.3);
  font-size: .9rem;
}

.brand-app {
  font-size: .95rem;
  font-weight: 600;
  color: rgba(255,255,255,.9);
}

.version {
  font-size: .7em;
  font-weight: 400;
  opacity: .7;
  vertical-align: super;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1.4rem;
}

.header-brand { display: flex; align-items: baseline; gap: .5rem; }

.header-user {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.username-label {
  color: rgba(255,255,255,.7);
  font-size: .85rem;
}

.badge-editor {
  background: var(--teal);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.7);
  padding: .3rem .7rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
  transition: all .15s;
}

.btn-logout:hover {
  border-color: rgba(255,255,255,.6);
  color: #fff;
}

/* ── Tab nav ──────────────────────────────────────────────────────────────── */
.tab-nav {
  background: var(--navy-dark);
  padding: 0 1.4rem;
  display: flex;
  gap: .1rem;
  border-bottom: 2px solid rgba(255,255,255,.08);
}

.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.5);
  padding: .65rem 1.1rem;
  font: inherit;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: rgba(255,255,255,.8); }

.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--teal);
}

/* ── Main layout ──────────────────────────────────────────────────────────── */
main { padding: 1.2rem 1.4rem; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #0a6665; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: #fff;
  color: var(--gray-800);
  border: 1px solid var(--gray-200);
  padding: .42rem .9rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: .875rem;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  display: inline-block;
}
.btn-secondary:hover { background: var(--gray-100); }

.btn-copy-ok {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: .5rem 1.4rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .03em;
  transition: background .15s;
}
.btn-copy-ok:hover { background: var(--teal); }

.btn-fix {
  background: var(--green);
  color: #fff;
  border: none;
  padding: .25rem .65rem;
  border-radius: 4px;
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-fix:hover { background: var(--green-dk); }

.btn-dismiss {
  background: transparent;
  color: var(--gray-400);
  border: 1px solid var(--gray-200);
  padding: .22rem .6rem;
  border-radius: 4px;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
  transition: all .15s;
}
.btn-dismiss:hover {
  background: var(--gray-100);
  color: var(--gray-800);
  border-color: var(--gray-400);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid #f0c0c0;
  padding: .25rem .6rem;
  border-radius: 4px;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
  transition: all .15s;
}
.btn-danger:hover { background: #fef0f0; }

/* ── Input section ────────────────────────────────────────────────────────── */
.input-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.input-header h2 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-600);
}

.input-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.wp-context {
  font-size: .8rem;
  color: var(--gray-600);
  font-style: italic;
}

#article-input {
  width: 100%;
  min-height: 160px;
  max-height: 320px;
  padding: .9rem 1rem;
  border: none;
  font: inherit;
  font-size: .9rem;
  line-height: 1.6;
  resize: vertical;
  color: var(--text);
}
#article-input:focus { outline: none; }

/* ── Status bar ───────────────────────────────────────────────────────────── */
.status-bar {
  padding: .6rem 1rem;
  background: var(--teal-lt);
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--teal);
  margin-bottom: .8rem;
}

.status-bar.error {
  background: #fef0f0;
  border-color: #f0c0c0;
  color: var(--red);
}

/* ── Output toolbar ───────────────────────────────────────────────────────── */
.output-toolbar {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: .75rem;
}

.output-toolbar--bottom { margin-top: .75rem; margin-bottom: 0; }

.output-stats {
  font-size: .8rem;
  color: var(--gray-600);
  flex: 1;
}

.copy-feedback {
  font-size: .82rem;
  color: var(--green);
  font-weight: 600;
}

/* ── Three-column table ───────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

#article-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#article-table thead tr {
  background: var(--navy);
}

#article-table th {
  padding: .55rem .8rem;
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.col-copy-h   { width: 40%; }
.col-issues-h { width: 35%; }
.col-really-h { width: 25%; }

.col-hint {
  font-weight: 400;
  opacity: .6;
  text-transform: none;
  letter-spacing: 0;
}

#article-table tbody tr {
  border-bottom: 1px solid var(--gray-200);
}

#article-table tbody tr:last-child { border-bottom: none; }

#article-table tbody tr:nth-child(even) td.col-copy { background: var(--gray-50); }

td.col-copy   { background: #fff; vertical-align: top; padding: 0; width: 40%; }
td.col-issues { background: var(--amber-lt); vertical-align: top; padding: .6rem .75rem; width: 35%; }
td.col-really { background: var(--blue-lt); vertical-align: top; padding: .6rem .75rem; width: 25%; }

/* Subheading rows */
tr.is-subheading td.col-copy,
tr.is-subheading td.col-copy .para-text { background: #f5f6ff; }
tr.is-subheading .para-text { font-weight: 700; font-size: .9rem; }

tr.is-caption td.col-copy,
tr.is-caption td.col-copy .para-text { background: #f8f8f8; }
tr.is-caption .para-text { font-style: italic; color: var(--gray-600); font-size: .85rem; }

/* Editable paragraph text */
.para-text {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: .65rem .8rem;
  font: inherit;
  font-size: .88rem;
  line-height: 1.65;
  color: var(--text);
  border: none;
  outline: none;
  resize: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: transparent;
}

.para-text:focus {
  background: #fafffe;
  box-shadow: inset 2px 0 0 var(--teal);
}

.para-text.updated {
  background: #f0fff4;
  transition: background 1s ease-out;
}

/* Issue items */
.issue-item {
  margin-bottom: .6rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--amber-bd);
}
.issue-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.issue-type {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .1rem .4rem;
  border-radius: 3px;
  margin-bottom: .3rem;
  background: var(--amber-bd);
  color: var(--gray-800);
}

.issue-type.spelling    { background: #fde8e8; color: #8b1a1a; }
.issue-type.grammar     { background: #fde8e8; color: #8b1a1a; }
.issue-type.punctuation { background: #fde8e8; color: #8b1a1a; }
.issue-type.style       { background: #e8edfd; color: #1a3a8b; }
.issue-type.house_style { background: #e8f5e9; color: #1a5c2a; }
.issue-type.name_consistency { background: #f3e8fd; color: #5a1a8b; }

.issue-desc {
  font-size: .83rem;
  line-height: 1.45;
  color: var(--gray-800);
  margin-bottom: .35rem;
}

.issue-actions {
  display: flex;
  gap: .4rem;
}

/* Really items */
.really-item {
  margin-bottom: .6rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--blue-bd);
}
.really-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.really-desc {
  font-size: .83rem;
  line-height: 1.45;
  color: var(--gray-800);
  margin-bottom: .35rem;
}

/* Per-paragraph actions (Copy paragraph / Undo fix) */
.para-actions {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .25rem .8rem .4rem;
  border-top: 1px solid var(--gray-200);
}

.btn-copy-para {
  background: transparent;
  color: var(--teal);
  border: 1px solid var(--teal);
  padding: .15rem .55rem;
  border-radius: 4px;
  font: inherit;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-copy-para:hover { background: var(--teal); color: #fff; }
.btn-copy-para:disabled { opacity: .7; cursor: default; }

.btn-undo {
  background: transparent;
  color: var(--gray-600);
  border: none;
  padding: 0;
  font: inherit;
  font-size: .75rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-undo:hover { color: var(--navy); }

/* No issues/really placeholder */
.col-empty {
  color: var(--gray-400);
  font-size: .78rem;
  font-style: italic;
}

/* ── Tags section ─────────────────────────────────────────────────────────── */
.tags-section {
  margin-top: 1.2rem;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}

.tags-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: .3rem;
}

.tags-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--gray-800);
  flex: 1;
}

.tags-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.tags-hint {
  font-size: .78rem;
  color: var(--gray-400);
  margin-bottom: .7rem;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--teal-lt);
  border: 1px solid var(--teal);
  color: var(--navy);
  font-size: .82rem;
  font-weight: 500;
  padding: .25rem .55rem .25rem .65rem;
  border-radius: 20px;
  white-space: nowrap;
}

.tag-remove {
  background: transparent;
  border: none;
  color: var(--teal);
  font-size: .75rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  opacity: .7;
  transition: opacity .15s;
}
.tag-remove:hover { opacity: 1; color: var(--red); }

/* ── Section headers ──────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--gray-200);
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
}

.section-actions { display: flex; gap: .5rem; align-items: center; }

/* ── Style guide list ─────────────────────────────────────────────────────── */
.sg-category {
  margin-bottom: 1.4rem;
}

.sg-category-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-600);
  padding: .35rem .75rem;
  background: var(--gray-100);
  border-radius: 4px;
  margin-bottom: .5rem;
}

.sg-rule {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .55rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: .4rem;
  transition: border-color .15s;
}

.sg-rule:hover { border-color: var(--gray-400); }

.sg-rule.inactive { opacity: .5; }

.sg-rule-text {
  flex: 1;
  font-size: .87rem;
  line-height: 1.5;
  color: var(--text);
}

.sg-rule-inactive-label {
  font-size: .72rem;
  color: var(--gray-400);
  font-style: italic;
}

.sg-rule-actions { display: flex; gap: .35rem; flex-shrink: 0; }

/* ── Rule form ────────────────────────────────────────────────────────────── */
.rule-form {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.rule-form-inner { padding: 1rem 1.2rem; }

.rule-form h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: .8rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.form-actions {
  display: flex;
  gap: .5rem;
  margin-top: .8rem;
}

/* ── WordPress drafts ─────────────────────────────────────────────────────── */
.wp-note {
  font-size: .82rem;
  color: var(--gray-600);
  margin-bottom: .9rem;
  padding: .5rem .75rem;
  background: var(--blue-lt);
  border-left: 3px solid #4a90e2;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.draft-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .9rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: .4rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.draft-item:hover { border-color: var(--teal); background: var(--teal-lt); }

.draft-title {
  flex: 1;
  font-size: .88rem;
  font-weight: 600;
  color: var(--navy);
}

.draft-modified {
  font-size: .78rem;
  color: var(--gray-400);
}

/* ── Users table ──────────────────────────────────────────────────────────── */
.users-table, .audit-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.users-table th, .audit-table th {
  background: var(--navy);
  color: #fff;
  padding: .5rem .75rem;
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.users-table td, .audit-table td {
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--gray-200);
  font-size: .85rem;
}

.users-table tr:last-child td, .audit-table tr:last-child td { border-bottom: none; }

.users-table tr:hover td, .audit-table tr:hover td { background: var(--gray-50); }

.role-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .12rem .4rem;
  border-radius: 3px;
  background: var(--gray-200);
  color: var(--gray-800);
}
.role-badge.editor { background: var(--teal); color: #fff; }

.audit-action {
  font-family: var(--mono);
  font-size: .78rem;
  background: var(--gray-100);
  padding: .1rem .35rem;
  border-radius: 3px;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.loading-msg {
  color: var(--gray-600);
  font-style: italic;
  font-size: .85rem;
  padding: .8rem 0;
}
