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

:root {
  --brand:       #1a3a5c;
  --brand-light: #2259a0;
  --accent:      #e8a020;
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --border:      #dde2ea;
  --text:        #1e2532;
  --muted:       #6b7a94;
  --danger:      #c0392b;
  --success:     #1d7a46;
  --sidebar-w:   240px;
  --radius:      8px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

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

/* ── Layout ───────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--brand);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 22px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo .company { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .6; }
.sidebar-logo .portal-name { font-size: 17px; font-weight: 700; line-height: 1.2; margin-top: 2px; }

nav.sidebar-nav { flex: 1; padding: 10px 0; }
nav.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.82);
  font-size: 14px;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
nav.sidebar-nav a:hover, nav.sidebar-nav a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  text-decoration: none;
  border-left-color: var(--accent);
}
nav.sidebar-nav .nav-section {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.4); padding: 16px 20px 4px;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 13px; color: rgba(255,255,255,.7);
}
.sidebar-footer a { color: rgba(255,255,255,.7); }
.sidebar-footer a:hover { color: #fff; }

/* ── Main content ─────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ──────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-user { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.topbar-user span { font-weight: 600; color: var(--text); }
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0; border-radius: 2px; }

/* ── Page content ─────────────────────────────────────── */
.content { padding: 28px; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--brand); }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary   { background: var(--brand-light); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-sm        { padding: 5px 12px; font-size: 13px; }
.btn-icon      { padding: 6px 10px; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--brand-light); }
.form-group textarea { resize: vertical; min-height: 120px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type=checkbox] { width: auto; }

/* ── Alert / flash ────────────────────────────────────── */
.alert { padding: 12px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }
.alert-success { background: #d4f1e4; color: var(--success); border: 1px solid #a8dfc0; }
.alert-danger  { background: #fde8e8; color: var(--danger);  border: 1px solid #f5b7b1; }
.alert-info    { background: #dce9f7; color: var(--brand);   border: 1px solid #a9c5ed; }

/* ── Tables ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
table th { background: var(--bg); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 14px; text-align: left; border-bottom: 2px solid var(--border); }
table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #f9fafb; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-admin  { background: #fff3cd; color: #856404; }
.badge-staff  { background: #d1ecf1; color: #0c5460; }
.badge-pinned { background: #fde8d8; color: #8b4513; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Login page ───────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--brand); }
.login-box { background: var(--surface); border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.25); padding: 40px 36px; width: 100%; max-width: 400px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .company { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.login-logo .portal  { font-size: 22px; font-weight: 700; color: var(--brand); margin-top: 4px; }
.login-box h2 { font-size: 18px; font-weight: 600; margin-bottom: 22px; }

/* ── Dashboard ────────────────────────────────────────── */
.quick-links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.quick-link-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 14px; text-align: center; color: var(--brand);
  box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s;
  text-decoration: none;
}
.quick-link-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: translateY(-2px); text-decoration: none; }
.quick-link-icon { font-size: 28px; margin-bottom: 8px; }
.quick-link-label { font-size: 13px; font-weight: 600; }

.announcement-list { list-style: none; }
.announcement-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.announcement-item:last-child { border-bottom: none; }
.announcement-item h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.announcement-item .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.announcement-item p { font-size: 14px; color: #444; }

/* ── Stats cards ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow); }
.stat-card .stat-num { font-size: 32px; font-weight: 700; color: var(--brand-light); }
.stat-card .stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }

/* ── FAQ ──────────────────────────────────────────────── */
.faq-search { display: flex; gap: 10px; margin-bottom: 24px; }
.faq-search input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.faq-category { margin-bottom: 32px; }
.faq-category h2 { font-size: 16px; font-weight: 700; color: var(--brand); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
details.faq-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); }
details.faq-item summary { padding: 14px 16px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.faq-item summary::after { content: '+'; font-size: 18px; color: var(--brand-light); }
details.faq-item[open] summary::after { content: '−'; }
details.faq-item summary::-webkit-details-marker { display: none; }
.faq-answer { padding: 0 16px 16px; font-size: 14px; color: #444; border-top: 1px solid var(--border); padding-top: 12px; }

/* ── KB ───────────────────────────────────────────────── */
.kb-search { display: flex; gap: 10px; margin-bottom: 24px; }
.kb-search input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.article-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.article-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: box-shadow .15s; }
.article-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.article-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.article-card h3 a { color: var(--text); }
.article-card h3 a:hover { color: var(--brand-light); }
.article-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: #eef2f7; color: var(--brand); padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.article-body { font-size: 15px; line-height: 1.7; color: #333; }
.article-body h1,.article-body h2,.article-body h3 { margin: 20px 0 8px; color: var(--brand); }
.article-body p { margin-bottom: 12px; }
.article-body ul,.article-body ol { margin: 8px 0 12px 24px; }
.article-body code { background: #f0f3f8; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.article-body pre { background: #1e2532; color: #e0e6f0; padding: 16px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 14px; }
.article-body pre code { background: none; padding: 0; color: inherit; }

/* ── Error page ───────────────────────────────────────── */
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 64px; font-weight: 800; color: var(--border); }
.error-page h2 { font-size: 22px; font-weight: 600; margin-bottom: 12px; }
.error-page p { color: var(--muted); margin-bottom: 24px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .hamburger { display: block; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .article-grid { grid-template-columns: 1fr; }
  .login-box { margin: 16px; padding: 28px 20px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
