/* KPI System — white-first theme with teal accent (#0FA89E). No external fonts or icon libraries. */
:root {
  --bg: #f7f9fb;
  --card: #ffffff;
  --text: #1e293b;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #0fa89e;
  --accent-600: #0b8a82;
  --accent-50: #e8f8f6;
  --accent-200: #a7e6e0;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --ok: #059669;
  --ok-50: #ecfdf5;
  --warn-50: #fffbeb;
  --border: #e6ebf1;
  --border-2: #d5dde6;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .05);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Sarabun', 'Noto Sans Thai', 'Noto Sans Thai Looped', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 .9rem; color: var(--text); }
h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 .75rem; }
a { color: var(--accent-600); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent-200); outline-offset: 2px; }

.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.2em; }

/* ---------- Brand ---------- */
.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  font-weight: 800; font-size: 1.02rem; color: var(--text); letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent);
  display: grid; place-items: center; color: #fff;
}
.brand-mark svg { width: 18px; height: 18px; }

/* ---------- Sidebar (desktop) ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.2rem .9rem 1rem; z-index: 20;
}
.sidebar .brand { padding: .2rem .5rem 1.2rem; }
.side-nav { flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 1.1rem; }
.nav-group-title {
  margin: 0 0 .4rem .6rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: #94a3b8;
}
.nav-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .75rem; border-radius: 10px; color: var(--text-2);
  font-weight: 500; font-size: .95rem; margin-bottom: .15rem;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-50); color: var(--accent-600); font-weight: 700; }
.nav-link.active .icon { color: var(--accent); }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: .8rem; }
.user-card { display: flex; align-items: center; gap: .65rem; padding: .3rem .4rem .6rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent-50); color: var(--accent-600);
  display: grid; place-items: center; font-weight: 700; font-size: .82rem; flex: none;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-name { font-weight: 600; font-size: .9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-roles { font-size: .72rem; color: var(--accent-600); }
.btn-block { width: 100%; justify-content: flex-start; }

/* ---------- Topbar (mobile only) ---------- */
.topbar {
  display: none; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .7rem 1rem; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 15;
}
.topbar-user { font-size: .85rem; color: var(--muted); }

/* ---------- Main ---------- */
.has-sidebar .app-main { margin-left: var(--sidebar-w); }
.app-main { max-width: 1140px; margin: 1.75rem auto 3rem; padding: 0 1.25rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head p { margin: .15rem 0 0; color: var(--muted); font-size: .92rem; }

/* ---------- Cards ---------- */
.card, .status-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 1.5rem; margin-bottom: 1.25rem;
}
.status-card { max-width: 460px; margin: 10vh auto; text-align: center; padding: 2.25rem 1.75rem; }
.status-icon {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 1rem;
  display: grid; place-items: center; background: var(--danger-50); color: var(--danger);
}
.status-icon.status-icon-info { background: var(--accent-50); color: var(--accent-600); }
.status-icon svg { width: 26px; height: 26px; }
.status-code { font-size: .8rem; font-weight: 700; letter-spacing: .08em; color: var(--muted); margin-bottom: .25rem; }

/* ---------- Auth (split layout) ---------- */
.auth-body { background: #eef6f5; }
.auth-main { margin: 0; max-width: none; padding: 0; min-height: 100vh; display: grid; place-items: center; }
.auth-split {
  display: grid; grid-template-columns: 1.05fr 1fr; width: min(960px, 94vw); min-height: 540px;
  margin: 4vh auto; background: #fff; border-radius: 22px; overflow: hidden; box-shadow: 0 20px 60px rgba(15, 23, 42, .12);
}
.auth-panel {
  position: relative; background: linear-gradient(160deg, #13b8ad 0%, var(--accent) 60%, #0b8a82 100%);
  color: #fff; display: flex; align-items: center; justify-content: center; padding: 2.5rem;
  border-radius: 0 50% 50% 0 / 0 40% 40% 0;
}
.auth-panel-inner { max-width: 300px; text-align: center; }
.auth-panel .brand-mark { background: rgba(255, 255, 255, .2); margin: 0 auto 1.25rem; width: 48px; height: 48px; border-radius: 14px; }
.auth-panel .brand-mark svg { width: 24px; height: 24px; }
.auth-panel-title { font-size: 1.8rem; font-weight: 800; margin: 0 0 .6rem; color: #fff; }
.auth-panel-text { margin: 0 0 1.25rem; font-size: 1rem; color: #fff; }
.auth-panel-note { font-size: .86rem; color: #f0fdfa; margin: 0; }

.auth-card { background: transparent; border: none; box-shadow: none; margin: 0; padding: 2.5rem 2.25rem; display: flex; flex-direction: column; justify-content: center; }
.auth-brand { display: none; }
.auth-card h1 { text-align: left; font-size: 1.7rem; margin-bottom: .2rem; }
.auth-card .lead { color: var(--muted); margin: 0 0 1.25rem; font-size: .92rem; }
.auth-card form { display: block; }

label { display: block; font-size: .86rem; margin: .95rem 0 .35rem; font-weight: 600; color: var(--text-2); }
input, select {
  width: 100%; padding: .72rem .9rem; border: 1px solid var(--border-2); border-radius: 10px;
  font: inherit; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #a0aec0; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-50); }
form > button[type=submit] { margin-top: 1.1rem; padding: .75rem 1rem; font-size: 1rem; }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 2.6rem; }
.input-icon { position: absolute; right: .9rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #94a3b8; pointer-events: none; }

.auth-links { margin: .6rem 0 0; font-size: .88rem; }
.auth-links-right { text-align: right; }
.auth-links a { color: var(--accent-600); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--border-2);
  background: #fff; color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: #f8fafc; text-decoration: none; border-color: #94a3b8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px rgba(15, 168, 158, .28);
}
.btn-primary:hover { background: var(--accent-600); border-color: transparent; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; border-color: transparent; color: var(--text-2); }
.btn-sm { padding: .32rem .65rem; font-size: .83rem; border-radius: 8px; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: var(--danger-50); border-color: #fca5a5; }
.actions { white-space: nowrap; }
.actions .btn { margin: .15rem .25rem .15rem 0; }

/* ---------- Messages ---------- */
.form-error, .form-info {
  font-size: .9rem; margin: .75rem 0 0; padding: .6rem .8rem; border-radius: 10px; border: 1px solid;
}
.form-error { color: #991b1b; background: var(--danger-50); border-color: #fecaca; }
.form-info { color: #065f46; background: var(--ok-50); border-color: #a7f3d0; }
.hint, .muted { color: var(--muted); font-size: .85rem; }
.note-box {
  margin-top: 1.25rem; padding: .7rem .85rem; border-radius: 10px;
  border: 1px solid var(--border); background-color: #f8fafc; color: var(--muted); font-size: .84rem;
}

/* ---------- Users table ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: 1fr; gap: .6rem; margin: 1rem 0; }
.filters select, .filters input { min-width: 0; }
.filters input[type=search] { padding-left: 2.4rem; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 12px center; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
th, td { padding: .75rem .9rem; text-align: left; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
th { background: #f8fafc; font-weight: 700; font-size: .8rem; color: var(--muted); letter-spacing: .02em; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f9fcfc; }
tbody tr:last-child td { border-bottom: none; }
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .18rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--accent-50); color: var(--accent-600); }
.badge-off { background: #f1f5f9; color: #64748b; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .9rem; color: var(--muted); font-size: .9rem; }

/* ---------- Stat cards (for KPI dashboard) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-50); color: var(--accent); margin-bottom: .6rem; }
.stat-label { font-size: .82rem; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }

/* ---------- Profile ---------- */
.profile-hero { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.profile-hero .avatar { width: 56px; height: 56px; font-size: 1.1rem; }
.profile-hero h1 { margin: 0; }
.profile-hero p { margin: 0; color: var(--muted); font-size: .9rem; }
.info-grid { display: grid; grid-template-columns: 150px 1fr; gap: .6rem 1rem; margin: 0; }
.info-grid dt { color: var(--muted); font-size: .9rem; }
.info-grid dd { margin: 0; font-weight: 600; }
.two-col { display: grid; gap: 1.25rem; }

/* ---------- Dialog ---------- */
dialog {
  border: none; border-radius: 16px; padding: 1.6rem 1.6rem 1.35rem;
  width: min(94vw, 540px); max-height: 90vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}
dialog::backdrop { background: rgba(15, 23, 42, .4); backdrop-filter: blur(2px); }
dialog h2 { font-size: 1.2rem; margin-bottom: .25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }
fieldset { border: 1px solid var(--border); border-radius: 12px; margin: .9rem 0 0; padding: .6rem .8rem .8rem; }
legend { font-weight: 700; font-size: .9rem; color: var(--text-2); padding: 0 .3rem; }
.role-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem .75rem; padding: .3rem 0 0; }
.chk {
  display: flex; align-items: center; gap: .5rem; font-weight: 500; margin: 0;
  padding: .4rem .55rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
}
.chk:hover { background: #f8fafc; }
.chk input { width: auto; accent-color: var(--accent); }
.chk.disabled { opacity: .5; cursor: not-allowed; }
fieldset:disabled { opacity: .75; }

/* ---------- Responsive ---------- */
@media (min-width: 720px) {
  .filters { grid-template-columns: 2fr 1fr 1fr auto; }
  .role-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }
  .info-grid dd { overflow-wrap: anywhere; }
}
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; width: min(440px, 94vw); min-height: 0; border-radius: 20px; }
  .auth-panel { border-radius: 0 0 50% 50% / 0 0 22% 22%; padding: 2rem 1.5rem 3.5rem; }
  .auth-panel-title { font-size: 1.4rem; }
  .auth-panel-note { display: none; }
  .auth-panel-text { font-size: .9rem; margin-bottom: 0; }
  .auth-panel-inner { max-width: none; }
  .auth-card { padding: 1.5rem 1.5rem 2rem; }
  .auth-card h1 { text-align: center; font-size: 1.4rem; }
  .auth-card .lead { text-align: center; }
}
@media (max-width: 720px) {
  .has-sidebar .sidebar { display: none; }
  .topbar { display: flex; }
  .has-sidebar .app-main { margin-left: 0; margin-top: 1rem; padding: 0 .9rem 5.5rem; }
  /* Bottom tab bar on mobile */
  .sidebar-footer { display: none; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: #fff; border-top: 1px solid var(--border); padding: .4rem .6rem calc(.4rem + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: .15rem; font-size: .72rem; color: var(--muted); padding: .3rem .6rem; border-radius: 10px; }
  .mobile-nav a.active { color: var(--accent-600); background: var(--accent-50); text-decoration: none; }
  .mobile-nav .icon { width: 20px; height: 20px; }

  #users-table thead { display: none; }
  #users-table, #users-table tbody, #users-table tr, #users-table td { display: block; width: 100%; }
  #users-table tr { border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem; margin-bottom: .6rem; background: #fff; }
  #users-table td { border: none; padding: .2rem 0; white-space: normal; }
  #users-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .75rem; }
  #users-table td.actions::before { content: none; }
  #users-table td.actions { margin-top: .35rem; }
  .auth-card { padding: 1.5rem 1.25rem 2rem; }
}
@media (max-width: 480px) {
  .info-grid { grid-template-columns: 1fr; }
  .info-grid dt { margin-top: .5rem; }
  .topbar-user { display: none; }
}

/* ---------- RA work-log module (ระบบบันทึกงาน RA) ---------- */
.ra-app { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ra-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.ra-tab {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; cursor: pointer;
  color: var(--muted); font-weight: 500; white-space: nowrap; font: inherit;
}
.ra-tab[aria-selected="true"] { color: var(--accent-600); border-bottom-color: var(--accent); font-weight: 600; }
.ra-tab:focus-visible, .ra-app button:focus-visible, .ra-app input:focus-visible,
.ra-app select:focus-visible, .ra-app textarea:focus-visible, .ra-drawer button:focus-visible,
.ra-drawer input:focus-visible, .ra-drawer select:focus-visible, .ra-drawer textarea:focus-visible,
.ra-app [data-open]:focus-visible, .ra-app [data-open-req]:focus-visible, .ra-app [data-open-prod]:focus-visible,
.ra-item-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ra-main { min-width: 0; }
.ra-loading, .ra-muted { color: var(--muted); font-size: .9rem; margin: .25rem 0; }
.ra-toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 14px; }
.ra-toolbar .ra-field { min-width: 160px; }
.ra-toolbar .ra-field.grow { flex: 1 1 260px; }
.ra-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: .85rem; color: var(--muted); }
.ra-field.full { grid-column: 1 / -1; }
.ra-field input, .ra-field select, .ra-field textarea, .ra-app input[type="search"], .ra-app input[type="month"] {
  background: #fff; border: 1px solid var(--border-2); border-radius: 10px; padding: .5rem .7rem;
  font: inherit; color: var(--text); min-width: 0; width: 100%;
}
.ra-field textarea { resize: vertical; min-height: 64px; }
.ra-check { display: flex; gap: .5rem; align-items: center; font-size: .9rem; color: var(--text-2); }
.ra-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 520px) { .ra-grid2 { grid-template-columns: 1fr; } }
.ra-small { padding: .25rem .6rem; font-size: .85rem; }
.ra-danger { color: var(--danger); border-color: #fecaca; }
.ra-actions-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.ra-h3 { font-size: .95rem; margin: 14px 0 6px; }
.ra-sect { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.ra-sect h3 { margin: 0 0 8px; font-size: .95rem; }

.ra-score {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; flex-wrap: wrap; gap: 16px 36px; align-items: center;
}
.ra-score-label { color: var(--muted); font-size: .85rem; }
.ra-score-big { font-size: 44px; font-weight: 700; line-height: 1.1; color: var(--accent-600); font-variant-numeric: tabular-nums; }
.ra-score-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.ra-stat { display: flex; flex-direction: column; gap: 2px; }
.ra-stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.ra-stat span { font-size: .8rem; color: var(--muted); }

.ra-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; }
.ra-kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px 18px; min-width: 0;
}
.ra-kpi h3 { margin: 0; font-size: .95rem; font-weight: 600; }
.ra-rule { font-size: .8rem; color: var(--muted); margin: 4px 0 0; min-height: 36px; }
.ra-row { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.ra-pct { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ra-kpi svg { width: 100%; height: auto; margin-top: 8px; display: block; }
.ra-base { stroke: var(--border-2); }
.ra-tgt { stroke: var(--text); stroke-dasharray: 3 3; opacity: .5; }
.ra-svgt { fill: var(--muted); font-size: 9.5px; font-family: inherit; }
.ra-b-good { fill: var(--ok); }
.ra-b-bad { fill: var(--danger); }

.ra-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; min-width: 0; }
.ra-panel h2 { font-size: .95rem; margin: 0 0 10px; }
.ra-item-row {
  display: flex; gap: 10px; justify-content: space-between; align-items: baseline; flex-wrap: wrap;
  padding: .6rem 0; border-top: 1px solid var(--border); cursor: pointer;
}
.ra-item-row:first-of-type { border-top: 0; }
.ra-item-row:hover { background: var(--accent-50); }
.ra-item-l { min-width: 0; flex: 1 1 200px; }
.ra-reason { font-size: .8rem; color: var(--danger); margin-top: 2px; }
.ra-warn-text { font-size: .8rem; color: #b45309; margin-top: 2px; }

.ra-pill { display: inline-block; border-radius: 99px; padding: 1px 10px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.ra-pill.good { background: var(--ok-50); color: var(--ok); }
.ra-pill.bad { background: var(--danger-50); color: var(--danger); }
.ra-pill.warn { background: var(--warn-50); color: #b45309; }
.ra-pill.mute { background: var(--accent-50); color: var(--accent-600); }
.ra-pill.none { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.ra-tablebox { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.ra-table { border-collapse: collapse; width: 100%; }
.ra-table-wide { min-width: 1040px; }
.ra-table th, .ra-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; font-size: .88rem; }
.ra-table th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #f8fafc; }
.ra-table tr[data-open], .ra-table tr[data-open-req], .ra-table tr[data-open-prod] { cursor: pointer; }
.ra-table tr[data-open]:hover td, .ra-table tr[data-open-req]:hover td, .ra-table tr[data-open-prod]:hover td { background: var(--accent-50); }
.ra-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ra-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; }

.ra-empty { text-align: center; padding: 40px 16px; color: var(--muted); background: var(--card); border: 1px dashed var(--border-2); border-radius: var(--radius); }
.ra-empty h2 { color: var(--text); font-size: 1.05rem; margin: 0 0 6px; }

.ra-scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 60; display: flex; justify-content: flex-end; }
.ra-drawer {
  background: #fff; width: min(680px, 100%); height: 100%; display: flex; flex-direction: column;
  box-shadow: -8px 0 30px rgba(15, 23, 42, .12);
}
.ra-drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.ra-drawer-head h2 { margin: 0; font-size: 1.05rem; }
.ra-drawer-body { overflow-y: auto; padding: 16px 18px; flex: 1; min-height: 0; }
.ra-drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); background: #fff; }
.ra-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-top: 10px; background: #fff; }
.ra-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ra-item-title { font-weight: 600; font-size: .9rem; }
.ra-revrow { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--border); font-size: .88rem; }
.ra-rev-actions { margin-left: auto; display: flex; gap: 6px; }
.ra-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: .9rem; margin: 0; }
.ra-dl dt { color: var(--muted); }
.ra-dl dd { margin: 0; }

.ra-toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 70; font-size: .9rem; box-shadow: var(--shadow);
}
.ra-toast[hidden] { display: none; }

@media (max-width: 720px) {
  .ra-table-wide, .ra-table { min-width: 0; }
  .ra-table thead { display: none; }
  .ra-table, .ra-table tbody, .ra-table tr, .ra-table td { display: block; width: 100%; }
  .ra-table tr { border: 1px solid var(--border); border-radius: 12px; padding: .5rem .75rem; margin-bottom: .6rem; background: #fff; }
  .ra-table td { border: none; padding: .2rem 0; }
  .ra-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; }
  .ra-drawer { width: 100%; }
  .ra-score-big { font-size: 36px; }
}
