/* ============================================================
   Security Inside theme — light + dark; tenant branding may override accent.
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #f3f7fa;
  --panel: #edf5f8;
  --surface: #ffffff;
  --border: #d6e3eb;
  --border-2: #e2ecf2;
  --text: #12293f;
  --muted: #33516b;
  --muted-2: #506a80;
  --accent: #2f6feb;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 111, 235, 0.12);
  --ok: #2e8b57; --ok-soft: rgba(46, 139, 87, 0.12);
  --warn: #b8860b; --warn-soft: rgba(184, 134, 11, 0.14);
  --danger: #d32f2f; --danger-soft: rgba(211, 47, 47, 0.1);
  --sidebar-bg: #153f6b; --sidebar-ink: #c8dce9; --sidebar-accent: #78d9e6;
  --shadow: 0 1px 3px rgba(21, 63, 107, 0.08);
  --radius: 10px;
  --table-checkbox-column-width: 48px;
  --table-number-column-width: 64px;
  --table-actions-column-width: 240px;
  --table-status-column-width: 160px;
  --table-date-column-width: 200px;
  --table-name-column-width: 180px;
  --table-email-column-width: 280px;
  --table-company-column-width: 200px;
  --table-department-column-width: 180px;
  --table-campaign-column-width: 240px;
  --table-template-column-width: 240px;
  --table-subject-column-width: 320px;
  --table-feature-column-width: 240px;
  --table-type-column-width: 160px;
  --table-risk-score-column-width: 160px;
  --table-grade-column-width: 140px;
  --table-engagement-column-width: 160px;
  --ev-open: #3a86c8; --ev-link: #1aa5b8; --ev-download: #9b4fd0;
  --ev-exec: #d98a1f; --ev-cred: #d94c47; --ev-qr: #6c5ce0;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1d2c; --panel: #1a344a; --surface: #142638;
  --border: #2b4357; --border-2: #243c50;
  --text: #e9f1f8; --muted: #acbfd0; --muted-2: #90aabd;
  --accent: #56c4d6; --accent-ink: #082a3b; --accent-soft: rgba(86, 196, 214, 0.14);
  --ok: #6fa859; --ok-soft: rgba(111, 168, 89, 0.14);
  --warn: #dabe4a; --warn-soft: rgba(218, 190, 74, 0.14);
  --danger: #ff6b66; --danger-soft: rgba(255, 107, 102, 0.12);
  --sidebar-bg: #0c2237; --sidebar-ink: #acc6d8; --sidebar-accent: #78d9e6;
  --shadow: 0 1px 3px rgba(4, 18, 31, 0.35);
  --ev-open: #5db7ff; --ev-link: #37cfe0; --ev-download: #be63e8;
  --ev-exec: #ffb347; --ev-cred: #ff6b66; --ev-qr: #9c8cff;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
html[data-theme-switching] * { transition: none !important; }
body { margin: 0; font-family: "Segoe UI", "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; transition: background .2s, color .2s; }
button { font:inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { filter: brightness(1.1); }

/* Layout: collapsible left sidebar + topbar */
.layout { display: grid; grid-template-columns: 232px minmax(0,1fr); min-height: 100vh; transition: grid-template-columns .18s ease; }
.layout.collapsed { grid-template-columns: 64px minmax(0,1fr); }
.sidebar { position:sticky; top:0; height:100vh; height:100dvh; min-width:0; overflow:hidden; background: var(--sidebar-bg); color: var(--sidebar-ink); padding: 12px 10px; display: flex; flex-direction: column; }
.sidebar-backdrop { display:none; }
.sidebar-header { display:flex; align-items:center; gap:6px; flex-shrink:0; min-height:50px; padding-bottom:10px; margin-bottom:8px; border-bottom:1px solid rgba(255,255,255,.1); }
.sidebar .brand { flex:1; min-width:0; display:flex; align-items:center; gap:8px; color:#fff; font-weight:700; font-size:16px; padding:4px 0; }
.sidebar .brand:has(.brand-logo) { flex-direction:column; align-items:flex-start; gap:6px; }
.sidebar .brand-text { white-space:normal; overflow-wrap:anywhere; line-height:1.4; }
.sidebar .brand .logo { width:22px; height:22px; flex:none; color:var(--sidebar-accent); }
.sidebar .brand .brand-logo { width:100%; height:64px; object-fit:contain; border-radius:6px; background:#fff; padding:6px; }
.layout.collapsed .sidebar-header { justify-content:center; }
.layout.collapsed .sidebar-header .brand { display:none; }
.nav { display: flex; flex-direction: column; gap: 2px; min-height:0; overflow-y:auto; scrollbar-width:thin; }
.nav a { display: flex; align-items: center; gap: 11px; color: var(--sidebar-ink); padding: 10px 11px;
  border-radius: 8px; white-space: nowrap; overflow: hidden; font-size: 14px; line-height:20px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; filter: none; }
.nav a.active { background: var(--accent); color: var(--accent-ink); }
.nav a .ico { flex: none; width: 18px; height: 18px; opacity: .9; }
.nav a.active .ico { opacity: 1; }
.layout.collapsed .nav a .label { display: none; }
.layout.collapsed .nav a { justify-content: center; padding: 10px 0; }
.sidebar .collapse-btn { display:flex; align-items:center; justify-content:center; flex-shrink:0; width:32px; height:32px; padding:6px; background:transparent; border:1px solid transparent; color:var(--sidebar-ink); border-radius:6px; cursor:pointer; }
.sidebar .collapse-btn svg { width:18px; height:18px; }
.sidebar .collapse-btn:hover { color:#fff; background:rgba(255,255,255,.08); border-color:rgba(255,255,255,.15); }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-heading { display:flex; align-items:center; gap:12px; flex:1 1 auto; min-width:0; }
.topbar-heading > div:first-child { min-width:0; overflow-wrap:anywhere; }
.topbar-heading .list-view-tools:not([hidden]) { flex-shrink:0; margin-bottom:0; }
.topbar .pills { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.content { padding: 24px; width: 100%; min-width: 0; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 12px; color: var(--text); }

/* pill toggles */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border-2);
  border-radius: 16px; color: var(--muted); font-size: 12.5px; background: transparent; cursor: pointer; white-space: nowrap; }
.pill:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.pill.user { color: var(--text); cursor: pointer; }
.pill.user:hover { border-color: var(--border-2); color: var(--text); }
.pill.on { border-color: var(--accent); color: var(--accent); }
.pill form { display: inline; margin: 0; }
.pill button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; width: auto; }
.pill svg { width: 14px; height: 14px; flex: none; }

/* Cards, stats */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 14px;
  box-shadow: var(--shadow); text-align: center; transition: transform .15s, border-color .15s; }
.stat:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat .label { color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); }
table.table-fixed-columns { width:auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
th, td { text-align: center; padding: 11px 14px; white-space: nowrap; }
th { background: var(--panel); color: var(--accent); font-weight: 600; font-size: 12px; letter-spacing: .35px;
  border-bottom: 1px solid var(--border); }
table thead th, table thead th[class] { text-align: center; }
td.center { text-align: center; }
table th.table-sort-heading { padding:0; }
.table-sort-button, .table-sort-link { display:flex; align-items:center; justify-content:center; gap:8px; width:100%;
  padding:11px 14px; color:inherit; font:inherit; letter-spacing:inherit; text-align:inherit;
  background:transparent; border:0; border-radius:0; cursor:pointer; white-space:nowrap; }
.table-sort-button:hover, .table-sort-link:hover { background:var(--accent-soft); text-decoration:none; }
.table-sort-button:focus-visible, .table-sort-link:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.table-sort-icon { color:var(--muted-2); font-weight:400; }
th[aria-sort] .table-sort-icon { color:var(--accent); }
td { color: var(--muted); font-size: 13.5px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover td { background: var(--bg); }
th.table-checkbox-cell, td.table-checkbox-cell { width:var(--table-checkbox-column-width); min-width:var(--table-checkbox-column-width); max-width:var(--table-checkbox-column-width); padding-inline:15px; text-align:center; }
.table-checkbox-cell > input[type="checkbox"] { display:block; width:18px; height:18px; padding:0; margin:0 auto; accent-color:var(--accent); }
table th.table-number-cell, table td.table-number-cell { width:var(--table-number-column-width); min-width:var(--table-number-column-width); max-width:var(--table-number-column-width); padding-inline:12px; text-align:center; font-variant-numeric:tabular-nums; white-space:normal; overflow-wrap:anywhere; }
table th.table-actions-cell, table td.table-actions-cell { width:var(--table-actions-column-width); min-width:var(--table-actions-column-width); max-width:var(--table-actions-column-width); padding-inline:12px; text-align:center; white-space:normal; }
table td.target-actions-cell { text-align:center; }
table th.table-status-cell, table td.table-status-cell { width:var(--table-status-column-width); min-width:var(--table-status-column-width); max-width:var(--table-status-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-date-cell, table td.table-date-cell { width:var(--table-date-column-width); min-width:var(--table-date-column-width); max-width:var(--table-date-column-width); padding-inline:12px; text-align:center; font-variant-numeric:tabular-nums; white-space:normal; overflow-wrap:anywhere; }
table th.table-name-cell, table td.table-name-cell { width:var(--table-name-column-width); min-width:var(--table-name-column-width); max-width:var(--table-name-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-email-cell, table td.table-email-cell { width:var(--table-email-column-width); min-width:var(--table-email-column-width); max-width:var(--table-email-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-company-cell, table td.table-company-cell { width:var(--table-company-column-width); min-width:var(--table-company-column-width); max-width:var(--table-company-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-department-cell, table td.table-department-cell { width:var(--table-department-column-width); min-width:var(--table-department-column-width); max-width:var(--table-department-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-campaign-cell, table td.table-campaign-cell { width:var(--table-campaign-column-width); min-width:var(--table-campaign-column-width); max-width:var(--table-campaign-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-template-cell, table td.table-template-cell { width:var(--table-template-column-width); min-width:var(--table-template-column-width); max-width:var(--table-template-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-subject-cell, table td.table-subject-cell { width:var(--table-subject-column-width); min-width:var(--table-subject-column-width); max-width:var(--table-subject-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-feature-cell, table td.table-feature-cell { width:var(--table-feature-column-width); min-width:var(--table-feature-column-width); max-width:var(--table-feature-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-type-cell, table td.table-type-cell { width:var(--table-type-column-width); min-width:var(--table-type-column-width); max-width:var(--table-type-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-risk-score-cell, table td.table-risk-score-cell { width:var(--table-risk-score-column-width); min-width:var(--table-risk-score-column-width); max-width:var(--table-risk-score-column-width); padding-inline:12px; text-align:center; font-variant-numeric:tabular-nums; white-space:normal; overflow-wrap:anywhere; }
table th.table-grade-cell, table td.table-grade-cell { width:var(--table-grade-column-width); min-width:var(--table-grade-column-width); max-width:var(--table-grade-column-width); padding-inline:12px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
table th.table-engagement-cell, table td.table-engagement-cell { width:var(--table-engagement-column-width); min-width:var(--table-engagement-column-width); max-width:var(--table-engagement-column-width); padding-inline:12px; text-align:center; font-variant-numeric:tabular-nums; white-space:normal; overflow-wrap:anywhere; }
table th:is(.table-status-cell, .table-date-cell, .table-name-cell, .table-email-cell, .table-company-cell, .table-department-cell, .table-campaign-cell, .table-template-cell, .table-subject-cell, .table-feature-cell, .table-type-cell, .table-risk-score-cell, .table-grade-cell, .table-engagement-cell).table-sort-heading, table th:is(.table-status-cell, .table-date-cell, .table-name-cell, .table-email-cell, .table-company-cell, .table-department-cell, .table-campaign-cell, .table-template-cell, .table-subject-cell, .table-feature-cell, .table-type-cell, .table-risk-score-cell, .table-grade-cell, .table-engagement-cell):has(> .acct-sort) { padding:0; }
table th:is(.table-status-cell, .table-date-cell, .table-name-cell, .table-email-cell, .table-company-cell, .table-department-cell, .table-campaign-cell, .table-template-cell, .table-subject-cell, .table-feature-cell, .table-type-cell, .table-risk-score-cell, .table-grade-cell, .table-engagement-cell) > :is(.table-sort-button, .table-sort-link, .acct-sort) { padding-inline:12px; }
.table-status-cell .badge, .table-template-cell .badge, .table-type-cell .badge { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
.table-feature-cell .feat { max-width:calc(100% - 4px); white-space:normal; overflow-wrap:anywhere; }
.table-grade-cell :is(.badge, .risk-grade) { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
table th.table-engagement-cell > :is(.table-sort-button, .table-sort-link) { white-space:normal; overflow-wrap:anywhere; }
.table-engagement-cell .metric-rate { max-width:100%; flex-wrap:wrap; white-space:normal; }
.table-engagement-cell .metric-count { max-width:100%; overflow-wrap:anywhere; }
.table-engagement-cell .report-progress-text { white-space:normal; }
table td :is(.template-mobile-features, .schedule-recipient-heading, .schedule-retry-counts) { justify-content:center; }
table td :is(.schedule-history-subject, .schedule-recipient-list, .schedule-recipient-warning, .schedule-retry-counts) { margin-inline:auto; }
table td .schedule-recipient-list { padding-inline:4px; }

/* Forms + buttons */
label { display: block; font-weight: 500; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font: inherit; line-height:20px; }
/* Native select arrows and padding differ between Safari and Chrome. */
select:not([multiple]):not([size]) { -webkit-appearance:none; appearance:none; padding-right:34px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23506a80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 11px center; background-size:14px 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
textarea { min-height: 120px; resize: vertical; }
.template-fields { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,2fr); gap:12px; }
.template-sender-fields { grid-template-columns:repeat(2,minmax(0,1fr)); }
.template-feature-options { gap:16px; }
.template-feature-options label { display:flex; align-items:center; gap:6px; margin:6px 0; }
.template-feature-options input { width:auto; }
.template-preview-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; align-items:start; }
.template-preview-card { min-width:0; }
.template-preview-card h2 { margin-top:0; }
.template-preview-card .muted { min-height:40px; }
.template-preview-frame { display:block; width:100%; height:460px; border:1px solid var(--border); border-radius:8px; background:#fff; }
.template-source-details { margin-top:16px; }
.template-source-details summary { cursor:pointer; color:var(--accent); font-weight:600; padding:6px 0; }
.template-source { height:260px; font-family:ui-monospace,Menlo,monospace; font-size:12px; line-height:1.6; tab-size:2; }
.template-edit-actions { position:sticky; top:0; z-index:20; padding:12px 16px; margin-bottom:16px;
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); }
.template-delete-actions { justify-content:flex-end; margin-bottom:20px; }
@media (max-width:1100px) { .template-preview-grid { grid-template-columns:minmax(0,1fr); } }
@media (max-width:720px) {
  .template-fields { grid-template-columns:minmax(0,1fr); gap:0; }
  .template-edit-actions { padding:10px; gap:8px; }
  .template-edit-actions > .spacer { display:none; }
  .template-edit-actions > .btn { flex:1; justify-content:center; }
  .template-edit-actions > .badge { order:1; flex-basis:100%; text-align:center; }
}
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--muted); border-color: var(--border-2); }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn.outline { background: transparent; color: var(--accent); }
.btn.outline:hover { background: var(--accent-soft); filter: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* List screens: filter bar, per-page/search toolbar, pagination, row actions */
.filter-bar { display:flex; align-items:center; flex-wrap:wrap; gap:12px 20px; padding:12px; border:1px solid var(--border); border-radius:9px; }
.filter-bar > div { display:flex; align-items:center; gap:8px; min-width:0; }
.filter-bar label { white-space:nowrap; margin:0; font-size:12px; }
.filter-bar select { width:210px; font-size:12px; }
.filter-bar > .btn { margin-left:auto; }
.table-toolbar { display:flex; flex-wrap:wrap; gap:12px; justify-content:space-between; align-items:center; padding:16px 0; }
.table-toolbar label { display:flex; align-items:center; gap:8px; margin:0; }
.table-toolbar select { width:70px; }
.table-toolbar input { width:230px; }
.table-pagination { display:flex; justify-content:space-between; align-items:center; gap:14px; flex-wrap:wrap; margin-top:16px; color:var(--muted-2); font-size:12px; }
.table-pagination > div { display:flex; align-items:center; gap:14px; }
.empty { padding:30px; text-align:center; color:var(--muted-2); font-size:13px; }
.actions { display:flex; align-items:center; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
table td.table-actions-cell > :is(.actions, .campaign-actions) { justify-content:center; }
.actions form { display:inline; }
/* Uniform action-button size so short (이력) and longer (리포트) labels line up.
   Matches both direct <a class="btn"> and buttons nested in <form>. */
.actions .btn { min-width:74px; justify-content:center; }
.num { font-variant-numeric:tabular-nums; }

/* Tabbed sections (list / create / upload style pages) */
.tabs { display:flex; gap:2px; border-bottom:1px solid var(--border); margin-bottom:20px; flex-wrap:wrap; }
.tabs .tab { padding:11px 18px; font-size:13.5px; font-weight:600; color:var(--muted); background:none;
  border:0; border-bottom:2px solid transparent; margin-bottom:-1px; cursor:pointer; text-decoration:none; }
.tabs .tab:hover { color:var(--text); }
.tabs .tab.active { color:var(--accent); border-bottom-color:var(--accent); }
.tab-panel { display:none; }
.tab-panel.active { display:block; }
/* A button that opens an inline editor (details/summary). */
summary.btn { list-style:none; }
summary.btn::-webkit-details-marker { display:none; }
summary.btn::marker { content:""; }

/* Account AI settings: saved defaults, regional model picker, company overrides. */
.ai-settings-card { padding:22px; }
.ai-settings-card h2 { margin:0; }
.ai-settings-heading { gap:12px; }
.ai-enabled-status { font-size:12px; margin:8px 0 18px; }
.ai-current-settings { display:grid; grid-template-columns:minmax(0,1fr) 220px; gap:14px; }
.ai-setting-value { padding:10px 12px; border:1px solid var(--border-2); border-radius:7px; background:var(--bg); min-height:40px; overflow-wrap:anywhere; }
.ai-query-controls { align-items:flex-end; margin-top:8px; }
.ai-query-controls select { width:260px; }
.ai-model-status { margin:12px 0 0; font-size:12px; white-space:normal; }
.ai-model-status:empty { display:none; }
.ai-model-status.error { color:var(--danger); padding:10px 12px; background:var(--danger-soft); border-radius:6px; }
.ai-model-choice { margin-top:14px; }
.ai-model-choice select { flex:1; min-width:220px; }
.ai-company-table { margin:18px 0 0; }
.ai-company-table td { padding:15px 14px; }
.ai-company-table .ai-company-model { white-space:normal; overflow-wrap:anywhere; max-width:480px; }
.ai-company-editor > td { background:var(--bg); }
.ai-company-controls { display:flex; flex-wrap:wrap; align-items:flex-end; gap:10px; }
.ai-company-controls > div:first-child { flex:0 1 245px; }
.ai-company-choice { flex:1 1 290px; min-width:0; }
.ai-company-controls select { max-width:100%; }
.ai-company-controls label { margin-top:0; }
@media (max-width:700px) {
  .ai-settings-card { padding:16px; }
  .ai-current-settings { grid-template-columns:minmax(0,1fr); gap:4px; }
  .ai-model-choice .row { align-items:stretch; }
  .ai-model-choice select { flex-basis:100%; min-width:0; }
}

/* Feature chips (template capabilities) */
.feat { display:inline-block; padding:3px 9px; border-radius:12px; font-size:11px; font-weight:600;
  margin:1px 2px; background:color-mix(in srgb, currentColor 14%, transparent); }
.feat.link { color:var(--ev-link); }
.feat.credential { color:var(--ev-cred); }
.feat.download { color:var(--ev-download); }
.feat.qr { color:var(--ev-qr); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.muted { background: rgba(128,128,128,.14); color: var(--muted); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* flash / auth / misc */
.list-view-tools:not([hidden]) { display:flex; align-items:center; justify-content:flex-end; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.list-view-reset-error { color:var(--danger); font-size:12px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.flash.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; }
.auth-card { width: 360px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* CSS bar charts */
.barchart { display: flex; flex-direction: column; gap: 8px; }
.barrow { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 10px; }
.barrow .bl { color: var(--muted); font-size: 13px; text-align: right; }
.bartrack { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; height: 20px; overflow: hidden; }
.barfill { height: 100%; background: var(--accent); border-radius: 6px 0 0 6px; min-width: 2px; }
.barfill.warn { background: var(--warn); }
.barfill.danger { background: var(--danger); }
.barrow .bv { font-variant-numeric: tabular-nums; font-size: 13px; }
/* Inline per-metric mini progress bars (reports list). */
.report-progress-text { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.progress-mini { height: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.progress-mini .bar { height: 100%; border-radius: 4px; }

/* Account-management tab bar. */
.acct-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.acct-tabs .tab { padding: 9px 15px; border-radius: 8px 8px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; border: 1px solid transparent; border-bottom: none; margin-bottom: -1px; }
.acct-tabs .tab:hover { color: var(--text); background: var(--surface); }
.acct-tabs .tab.active { color: var(--accent); background: var(--surface); border-color: var(--border); }
.acct-body.js-tabs [data-tab] { display: none; }
.acct-body.js-tabs [data-tab].tab-active { display: block; }

/* Account list: filter bar, security-status cell, and the collapsible
   "상세 관리" (detail management) editor row. */
.acct-filter { margin-bottom: 16px; }
.acct-filter .acct-filter-search { flex: 1 1 260px; }
.acct-filter .acct-filter-search input,
.acct-filter .acct-filter-company input { width: 100%; min-width: 160px; font-size: 12px; }
.acct-filter select { width: 170px; }
.acct-table td { white-space: nowrap; vertical-align: top; }
.acct-table .actions { align-items: flex-start; }
.acct-table th:has(.acct-sort) { padding:0; }
.acct-sort { display:flex; align-items:center; justify-content:center; gap:8px; padding:11px 14px; color:inherit; }
.acct-sort:hover { background:var(--accent-soft); text-decoration:none; }
.acct-sort:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.acct-sort-icon { color:var(--muted-2); }
.acct-table th[aria-sort] .acct-sort-icon { color:var(--accent); }
.sec-meta { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; }
.sec-meta small { font-size: 11px; }
[data-acct-toggle].active { border-color: var(--accent); color: var(--accent); }
.acct-editor > td { background: var(--bg); white-space: normal; }
.acct-editor-grid { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: flex-end; }
.acct-editor-field { min-width: 0; }
.acct-editor-field > label { margin-top: 0; color: var(--muted-2); font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; }

@media (max-width: 720px) {
  .layout, .layout.collapsed { grid-template-columns:64px minmax(0,1fr); }
  .main { grid-column:2; }
  .layout:not(.collapsed) .sidebar { position:fixed; left:0; top:0; width:232px; z-index:40; box-shadow:8px 0 28px rgba(0,0,0,.25); }
  .layout:not(.collapsed) .sidebar-backdrop { display:block; position:fixed; inset:0 0 0 232px; z-index:39; border:0; border-radius:0; background:rgba(0,0,0,.3); padding:0; }
  .topbar { padding:12px; flex-wrap:wrap; }
  .topbar .pills { gap:6px; }
  .topbar .pill { padding:0 8px; font-size:11px; }
}

@media (max-width: 600px) {
  .filter-bar > div { width:100%; }
  .filter-bar label { width:48px; flex:none; }
  .filter-bar select { width:100%; min-width:0; }
  .table-toolbar label:last-child { width:100%; }
  .table-toolbar input { width:100%; }
}

/* Template builder: pill toggle buttons (training features / language) */
.opt-group { display:flex; flex-wrap:wrap; gap:8px; }
.opt-btn { display:inline-flex; align-items:center; gap:6px; padding:8px 14px; border:1px solid var(--border);
  border-radius:10px; background:var(--surface); color:var(--muted); font-size:13px; font-weight:600; cursor:pointer;
  user-select:none; transition:border-color .12s, color .12s, background .12s; }
.opt-btn:hover { border-color:var(--accent); color:var(--text); }
.opt-btn:has(input:checked) { border-color:var(--accent); color:var(--accent);
  background:color-mix(in srgb, var(--accent) 10%, transparent); }
.opt-btn input { position:absolute; opacity:0; width:0; height:0; }
.prompt-examples { display:flex; flex-wrap:wrap; gap:8px 14px; margin-top:8px; font-size:12px; }
.prompt-examples #ai-examples { display:flex; flex-wrap:wrap; gap:8px 16px; min-width:0; }
.prompt-examples button { background:none; border:none; color:var(--accent); cursor:pointer; padding:0; font-size:12px; text-decoration:underline; }
.ci-drop { border:1.5px dashed var(--border); border-radius:12px; padding:22px; text-align:center; color:var(--muted-2);
  font-size:13px; cursor:pointer; transition:border-color .12s, background .12s; }
.ci-drop:hover, .ci-drop.dragover { border-color:var(--accent); background:var(--bg); }
.ci-drop input { display:none; }
.ci-drop .ci-name { display:block; margin-top:6px; color:var(--accent); font-weight:600; }
.ci-drop img { display:block; margin-left:auto; margin-right:auto; }

/* AI generate tab: mutual-exclusion hint, status line, and busy spinner. */
.opt-hint { margin-top:6px; font-size:12px; color:var(--muted-2); }
.ai-status { font-size:12.5px; font-weight:600; display:inline-flex; align-items:center; gap:6px; }
.ai-status.ok { color:var(--ok); }
.ai-status.err { color:var(--danger); }
.ai-status.warn { color:var(--warn, #d98a00); }
.ai-status.run { color:var(--muted); }
.spinner { display:inline-block; width:14px; height:14px; border:2px solid var(--border);
  border-top-color:var(--accent); border-radius:50%; animation:ai-spin .8s linear infinite;
  vertical-align:middle; }
@keyframes ai-spin { to { transform:rotate(360deg); } }

/* Company management: color swatch + red-outline preview button */
.swatch { display:inline-block; width:24px; height:24px; border-radius:6px; border:1px solid var(--border-2); vertical-align:middle; }
.btn.danger-outline { background:transparent; color:var(--danger); border-color:var(--danger); }
.btn.danger-outline:hover { background:var(--danger-soft); filter:none; }
.danger-text { color:var(--danger); }

/* Modal dialogs (branding editor, training-notice preview/editor) */
dialog.modal { border:none; padding:0; width:min(880px, 94vw); max-height:92vh; border-radius:14px;
  background:var(--surface); color:var(--text); box-shadow:0 24px 70px rgba(0,0,0,.5); overflow:hidden; }
dialog.modal.modal-lg { width:min(980px, 96vw); }
dialog.modal.notice-modal { width:min(1180px, 96vw); max-height:94vh; }
dialog.modal.notice-modal.is-editing { width:min(1480px, 96vw); }
dialog.modal.notice-modal .modal-head { background:var(--surface); padding:18px 22px; }
dialog.modal.notice-modal .modal-head strong { color:var(--accent); font-size:17px; }
dialog.modal.notice-modal .modal-body { padding:0; max-height:calc(94vh - 80px); }
.notice-controls { display:flex; gap:10px; align-items:center; flex-shrink:0; }
.notice-controls select { width:auto; margin:0; }
.notice-workspace { min-width:0; }
.notice-workspace.editing { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:20px; padding:20px; }
.notice-workspace > section { min-width:0; }
.notice-edit-pane[hidden] { display:none; }
.notice-edit-pane > label, .notice-preview-label { margin:0 0 10px; font-size:14px; font-weight:600; }
.notice-source-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; }
.notice-source-heading label { margin:0; font-size:14px; font-weight:600; }
.notice-source-help { font-size:12px; line-height:1.6; margin:0 0 12px; }
.notice-edit-pane textarea { width:100%; height:55vh; min-height:260px; font:12px/1.7 ui-monospace,Menlo,monospace; resize:vertical; tab-size:2; }
.notice-preview-label { display:none; }
.notice-workspace.editing .notice-preview-label { display:block; }
.notice-preview-pane iframe { display:block; width:100%; height:76vh; border:0; background:#fff; }
.notice-workspace.editing iframe { height:64vh; border:1px solid var(--border); border-radius:8px; }
.notice-editor-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:12px; }
.notice-editor-status { padding:0 20px 16px; margin:0; color:var(--muted); font-size:12px; }
.notice-editor-status.danger-text { color:var(--danger); }
.company-list-card > h2 { margin-top:0; }
@media (max-width:900px) {
  .notice-workspace.editing { grid-template-columns:minmax(0,1fr); }
  .notice-edit-pane textarea { height:32vh; }
  .notice-workspace.editing iframe { height:50vh; }
  .notice-modal .modal-head { flex-wrap:wrap; }
  .notice-controls { margin-left:auto; }
}
dialog.modal.template-edit-modal { width:min(1440px, 96vw); }
.template-editor-tabs { gap:8px; margin:14px 0 10px; }
.template-editor-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; align-items:start; }
.template-editor-grid > section { min-width:0; }
.template-editor-grid label { margin-top:0; min-height:32px; display:flex; align-items:center; }
.template-editor-grid .template-source { height:400px; }
.template-editor-preview-head { justify-content:space-between; min-height:32px; margin-bottom:4px; }
.template-editor-preview-frame { height:400px; min-height:200px; resize:vertical; overflow:hidden; padding-bottom:14px;
  border:1px solid var(--border); border-radius:6px; background:var(--surface); }
.template-editor-preview iframe { display:block; width:100%; height:100%; border:0; background:#fff; }
.template-editor-resize-hint { margin:6px 0 0; font-size:12px; }
.template-editor-status { margin:8px 0 0; min-height:20px; font-size:12px; }
.template-asset { border-top:1px solid var(--border); margin-top:18px; padding-top:18px; }
.template-asset [hidden] { display:none !important; }
.card > .template-asset { border-top:0; margin-top:0; padding-top:0; }
.asset-heading h2 { margin:0 0 4px; }
.asset-heading p { margin:0 0 14px; font-size:12px; }
.asset-current { display:flex; gap:12px; align-items:center; padding:12px 14px; border-radius:8px; background:var(--panel); margin-bottom:12px; }
.asset-icon { width:26px; height:26px; flex:none; color:var(--accent); }
.asset-current-text, .asset-selection { display:flex; flex:1; flex-direction:column; gap:4px; min-width:0; }
.asset-current-text > span, .asset-selection > span { font-size:12px; }
.asset-current-text strong, .asset-selection strong { overflow-wrap:anywhere; font-size:13px; }
.asset-drop { position:relative; display:flex; gap:14px; align-items:center; padding:18px; border:1.5px dashed var(--border); border-radius:8px; transition:background .15s,border-color .15s; }
.asset-drop.dragover, .asset-drop:focus-within { background:var(--accent-soft); border-color:var(--accent); }
.asset-choose { margin:0; font-size:13px; }
.asset-file-input { position:absolute; width:1px; height:1px; padding:0; border:0; opacity:0; }
.asset-upload-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:10px; }
.asset-upload-actions p { flex:1; margin:0; font-size:12px; }
.asset-status { margin:10px 0 0; font-size:13px; color:var(--ok); }
.asset-status.error { color:var(--danger); }
.template-asset [data-asset-reset] { margin-top:10px; }
@media (max-width:600px) {
  .asset-drop { flex-wrap:wrap; padding:14px; }
  .asset-choose { margin-left:auto; }
  .asset-upload-actions p { flex-basis:100%; }
}
@media (max-width:900px) {
  .template-editor-grid { grid-template-columns:minmax(0,1fr); }
  .template-editor-grid .template-source, .template-editor-preview-frame { height:320px; }
}
dialog.modal::backdrop { background:rgba(0,0,0,.55); }
dialog.modal .modal-head { display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:14px 18px; border-bottom:1px solid var(--border); background:var(--panel); }
dialog.modal .modal-head strong { font-size:15px; }
dialog.modal .modal-body { padding:18px; overflow:auto; max-height:calc(92vh - 58px); }
.modal-x { background:none; border:none; color:var(--muted); font-size:22px; line-height:1; cursor:pointer;
  padding:0 4px; width:auto; }
.modal-x:hover { color:var(--text); }

/* Inline company-branding editor (expands below the company row). */
.brand-editor > td { background:var(--bg); white-space:normal; }
.brand-form { padding:4px 2px; }
.brand-grid { display:flex; flex-wrap:wrap; gap:16px 22px; align-items:flex-start; }
.brand-field { display:flex; flex-direction:column; gap:6px; min-width:0; }
.brand-field > label:first-child { margin:0; color:var(--muted-2); font-size:11px; line-height:16px; text-transform:uppercase; letter-spacing:.5px; }
.brand-field input[name="name"] { width:240px; max-width:100%; height:48px; }
.brand-color-field input[type="color"] { width:72px; height:48px; padding:4px; }
.brand-logo-field { flex:1 1 300px; }
.logo-drop { display:flex; align-items:center; gap:12px; cursor:pointer; margin:0; padding:6px 12px;
  border:1.5px dashed var(--border-2); border-radius:9px; background:var(--surface);
  transition:border-color .15s, background .15s; min-height:48px; }
.logo-drop:hover, .logo-drop.dragover { border-color:var(--accent); background:var(--accent-soft); }
.logo-drop-preview { height:30px; max-width:150px; object-fit:contain; border-radius:4px; }
.logo-drop-hint { color:var(--muted); font-size:12px; }
.logo-remove { display:inline-flex; align-items:center; gap:6px; margin:0; font-size:12px; color:var(--muted); }
.logo-remove input { width:auto; }
.brand-actions { margin-left:auto; align-self:flex-end; }
@media (max-width:640px){
  .brand-grid { gap:12px; }
  .brand-field input[name="name"] { width:100%; }
  .brand-actions { margin-left:0; width:100%; }
}
