:root {
  --ink: #171717;
  --ink-2: #2d2d2d;
  --muted: #6f737a;
  --muted-2: #969aa1;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --surface: #ffffff;
  --background: #f4f5f6;
  --soft: #f8f9fa;
  --sidebar: #171717;
  --sidebar-soft: #242424;
  --success: #18733f;
  --success-bg: #eaf7ef;
  --warning: #9a5b08;
  --warning-bg: #fff6e7;
  --danger: #b42318;
  --danger-bg: #fff1f1;
  --info: #1d5fa7;
  --info-bg: #edf5ff;
  --shadow: 0 12px 34px rgba(20, 20, 20, .065);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-width: 278px;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100%; margin: 0; font-family: Tahoma, Arial, sans-serif; background: var(--background); color: var(--ink); font-size: 14px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
img { max-width: 100%; }
code { font-family: Consolas, monospace; font-size: 12px; direction: ltr; display: inline-block; }
small { color: var(--muted); }

.app-frame { min-height: 100vh; display: flex; direction: rtl; }
.sidebar { position: fixed; inset: 0 0 0 auto; z-index: 50; width: var(--sidebar-width); height: 100vh; display: flex; flex-direction: column; padding: 20px 16px 16px; background: var(--sidebar); color: #fff; overflow-y: auto; }
.sidebar-head { min-height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 10px; }
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { display: block; width: 190px; max-height: 45px; filter: invert(1); }
.sidebar-close { display: none; width: 36px; height: 36px; align-items: center; justify-content: center; border: 0; border-radius: 9px; background: #2e2e2e; color: #fff; font-size: 23px; }
.workspace-card { display: flex; align-items: center; gap: 11px; margin: 8px 4px 20px; padding: 12px; border: 1px solid #343434; border-radius: 13px; background: #202020; }
.workspace-card div { min-width: 0; display: grid; gap: 3px; }
.workspace-card strong { font-size: 13px; }
.workspace-card small { color: #a9a9a9; font-size: 11px; }
.workspace-mark { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 36px; border-radius: 10px; background: #fff; color: #171717; font-weight: 800; font-size: 11px; }
.side-nav { display: grid; gap: 3px; }
.nav-section { margin: 16px 12px 6px; color: #777; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.side-nav a { min-height: 43px; display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: #c8c8c8; text-decoration: none; transition: .16s ease; }
.side-nav a:hover { color: #fff; background: #242424; }
.side-nav a.active { color: #171717; background: #fff; font-weight: 700; }
.nav-icon { width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 25px; border-radius: 7px; background: rgba(255,255,255,.07); font-size: 14px; }
.side-nav a.active .nav-icon { background: #efefef; }
.nav-count { min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; margin-right: auto; padding: 0 6px; border-radius: 999px; background: #fff; color: #171717; font-size: 11px; }
.side-nav a.active .nav-count { background: #171717; color: #fff; }
.sidebar-foot { display: grid; gap: 10px; margin-top: auto; padding: 20px 5px 2px; }
.mode-chip { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 9px; background: #242424; color: #bdbdbd; font-size: 11px; }
.mode-chip span { width: 8px; height: 8px; border-radius: 50%; background: #d89b38; box-shadow: 0 0 0 3px rgba(216,155,56,.14); }
.mode-chip.live span { background: #3ab56b; box-shadow: 0 0 0 3px rgba(58,181,107,.14); }
.account-link { padding: 8px 11px; color: #aaa; text-decoration: none; font-size: 11px; }
.account-link:hover { color: #fff; }
.sidebar-overlay { display: none; }

.app-body { width: calc(100% - var(--sidebar-width)); min-width: 0; margin-right: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
.topbar-start { display: flex; align-items: center; gap: 13px; }
.topbar-start > div { display: grid; gap: 3px; }
.topbar-start strong { font-size: 15px; }
.topbar-start small { font-size: 11px; }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-avatar, .table-avatar, .list-avatar, .chat-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; text-transform: uppercase; }
.user-avatar { width: 38px; height: 38px; }
.user-copy { display: grid; gap: 2px; min-width: 110px; }
.user-copy strong { font-size: 12px; }
.user-copy small { font-size: 10px; }
.ghost-button { min-height: 36px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: #555; }
.ghost-button:hover { border-color: #aaa; color: var(--ink); }

.container { width: min(1540px, calc(100% - 48px)); margin: 24px auto 42px; }
.guest-container { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #fff 0, #f3f4f5 45%, #e9eaec 100%); }
.flash-stack { position: fixed; top: 88px; left: 24px; z-index: 90; width: min(420px, calc(100% - 32px)); display: grid; gap: 8px; }
.flash { padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow); transition: .25s ease; }
.flash-success { border-color: #b9dfc7; background: var(--success-bg); color: var(--success); }
.flash-error { border-color: #f1bdb8; background: var(--danger-bg); color: var(--danger); }
.flash-warning { border-color: #efd5a8; background: var(--warning-bg); color: var(--warning); }
.flash-hide { opacity: 0; transform: translateY(-8px); pointer-events: none; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 20px; }
.page-heading h1 { margin: 4px 0 7px; font-size: clamp(25px, 3vw, 36px); letter-spacing: -.02em; }
.page-heading p { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.75; }
.eyebrow { color: #777; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.heading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.back-link { display: inline-flex; margin-bottom: 8px; color: var(--muted); text-decoration: none; font-size: 12px; }
.back-link:hover { color: var(--ink); }
.status-badge { display: inline-flex; align-items: center; padding: 8px 13px; border: 1px solid #cce8d6; border-radius: 999px; background: var(--success-bg); color: var(--success); font-size: 12px; white-space: nowrap; }

.button, button.primary, button.secondary { min-height: 41px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; text-decoration: none; font-weight: 700; font-size: 12px; transition: .15s ease; }
.button.primary, button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.button.primary:hover, button.primary:hover { background: #000; }
.button.secondary, button.secondary { border-color: var(--line-strong); background: #fff; color: var(--ink); }
.button.secondary:hover, button.secondary:hover { border-color: #9ca3af; background: var(--soft); }
.button.danger, button.danger { border-color: #efc1bd; background: var(--danger-bg); color: var(--danger); }
.full-button { width: 100%; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--info); font-weight: 700; font-size: 12px; }
.danger-text { color: var(--danger) !important; }

.metric-grid { display: grid; gap: 14px; margin-bottom: 18px; }
.metric-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { min-height: 142px; display: grid; align-content: space-between; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: inherit; text-decoration: none; box-shadow: 0 5px 18px rgba(20,20,20,.025); }
.metric-card:hover { border-color: #c3c6ca; transform: translateY(-1px); }
.metric-card strong { font-size: 36px; line-height: 1; }
.metric-card small { font-size: 11px; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-alert { border-color: #efd5a8; background: #fffdf7; }
.metric-danger { border-color: #efc1bd; background: #fffafa; }
.secondary-metrics { margin-bottom: 22px; }
.mini-metric { min-height: 80px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: inherit; text-decoration: none; }
.mini-metric span { color: var(--muted); font-size: 12px; }
.mini-metric strong { font-size: 24px; }
.mini-metric.has-error { border-color: #efc1bd; color: var(--danger); }

.panel, .form-panel { margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 5px 20px rgba(20,20,20,.025); }
.panel { overflow: hidden; }
.form-panel { padding: 24px; }
.panel-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 19px; border-bottom: 1px solid var(--line); }
.panel-head h2, .action-panel h2, .action-panel h3 { margin: 0 0 5px; font-size: 16px; }
.panel-head p, .action-panel p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 11px; }
.panel-head > a { color: var(--info); text-decoration: none; font-size: 12px; font-weight: 700; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(290px, .8fr); gap: 18px; }
.panel-large { min-width: 0; }
.panel-footnote { margin: 0; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.simple-list { display: grid; }
.simple-list-row { min-height: 70px; display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid #f0f1f2; color: inherit; text-decoration: none; }
.simple-list-row:last-child { border-bottom: 0; }
.simple-list-row:hover { background: #fafafa; }
.list-avatar { width: 40px; height: 40px; }
.list-main { min-width: 0; display: grid; gap: 4px; }
.list-main strong, .list-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { display: flex; align-items: center; gap: 8px; }
.list-meta em { min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--ink); color: #fff; font-size: 10px; font-style: normal; }
.priority-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: #9ca3af; }
.priority-dot.priority-high { background: #d28a20; }
.priority-dot.priority-urgent { background: var(--danger); }

.health-list { display: grid; }
.health-list > div { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 18px; border-bottom: 1px solid #f0f1f2; }
.health-list > div:last-child { border-bottom: 0; }
.health-list span { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.health-list b { font-size: 12px; }
.health-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; }
.health-dot.ok { background: #2d9d5b; box-shadow: 0 0 0 4px rgba(45,157,91,.1); }
.health-dot.warn { background: #d28a20; box-shadow: 0 0 0 4px rgba(210,138,32,.1); }
.health-dot.bad { background: #d64035; box-shadow: 0 0 0 4px rgba(214,64,53,.1); }
.resource-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); }
.resource-grid > div { min-height: 94px; display: grid; place-content: center; gap: 5px; background: #fff; text-align: center; }
.resource-grid strong { font-size: 25px; }
.resource-grid span { color: var(--muted); font-size: 11px; }
.limit-meter { padding: 16px 18px; border-top: 1px solid var(--line); }
.limit-meter > div { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 11px; }
.limit-meter progress { width: 100%; height: 7px; accent-color: var(--ink); }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: right; }
.data-table th { padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafafa; color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f0f1f2; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fcfcfc; }
.data-table td > strong, .data-table td > small, .data-table td > a strong, .data-table td > a small { display: block; }
.data-table td > a { color: inherit; text-decoration: none; }
.compact-table td { padding-top: 10px; padding-bottom: 10px; }
.table-link { color: var(--info) !important; font-weight: 700; }
.person-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.person-cell > div { display: grid; gap: 3px; }
.table-avatar { width: 36px; height: 36px; flex: 0 0 36px; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.row-actions a { color: var(--info); text-decoration: none; font-size: 12px; font-weight: 700; }
.empty-inline { padding: 26px; color: var(--muted); text-align: center; }

.status-pill, .role-pill, .priority-label { display: inline-flex; align-items: center; justify-content: center; padding: 5px 9px; border-radius: 999px; white-space: nowrap; font-size: 10px; font-weight: 700; }
.status-pill { background: #f0f1f2; color: #5b6169; }
.status-active, .status-approved, .status-processed, .status-completed, .status-read, .status-delivered { background: var(--success-bg); color: var(--success); }
.status-inactive, .status-cancelled, .status-rejected, .status-failed, .status-critical { background: var(--danger-bg); color: var(--danger); }
.status-pending, .status-new, .status-queued, .status-warning { background: var(--warning-bg); color: var(--warning); }
.status-in_progress, .status-awaiting_approval, .status-revision_required, .status-sent, .status-info { background: var(--info-bg); color: var(--info); }
.role-pill { background: #f0f1f2; }
.role-admin { background: #ece8ff; color: #5c3db0; }
.role-supervisor { background: var(--info-bg); color: var(--info); }
.role-agent { background: var(--success-bg); color: var(--success); }
.role-designer { background: #fff0f6; color: #a23b6e; }
.priority-label { background: #f0f1f2; color: #5b6169; }
.priority-high { background: var(--warning-bg); color: var(--warning); }
.priority-urgent { background: var(--danger-bg); color: var(--danger); }

.filter-bar { display: grid; gap: 9px; align-items: center; margin-bottom: 16px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.filter-grid-5 { grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, .55fr)) auto; }
.inbox-filter-grid { grid-template-columns: minmax(220px, 1.2fr) repeat(5, minmax(120px, .55fr)) auto auto; }
.compact-filter { grid-template-columns: minmax(220px, 1fr) minmax(160px, .4fr) auto; max-width: 760px; }
.filter-bar input, .filter-bar select, .field input, .field select, .field textarea, .inspector-form input, .inspector-form select, .inspector-form textarea, .template-send-form input, .template-send-form select, .template-send-form textarea { width: 100%; min-height: 42px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 11px; background: #fff; color: var(--ink); outline: 0; }
.filter-bar input:focus, .filter-bar select:focus, .field input:focus, .field select:focus, .field textarea:focus, .inspector-form input:focus, .inspector-form select:focus, .inspector-form textarea:focus { border-color: #777; box-shadow: 0 0 0 3px rgba(23,23,23,.07); }
.checkbox-field { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.checkbox-field input { width: auto; min-height: auto; }

.structured-form { display: grid; gap: 18px; }
.form-section { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; }
.form-section h2 { margin: 0 0 15px; font-size: 15px; }
.form-grid { display: grid; gap: 15px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; align-content: start; gap: 7px; color: #3f4349; font-size: 12px; font-weight: 700; }
.field textarea { min-height: 110px; resize: vertical; }
.field small { line-height: 1.6; font-weight: 400; }
.field ul.errorlist, .form-errors ul { margin: 2px 0 0; padding: 0; list-style: none; color: var(--danger); font-size: 11px; font-weight: 400; }
.field-error input, .field-error select, .field-error textarea { border-color: #e7a8a3; }
.field-span-2 { grid-column: 1 / -1; }
.checkbox-stack { display: grid; gap: 11px; align-content: start; }
.toggle-field { display: flex; align-items: center; gap: 9px; min-height: 38px; color: #3f4349; font-size: 12px; font-weight: 700; }
.toggle-field input { width: 18px; height: 18px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding-top: 4px; }
.form-errors { padding: 12px 14px; border: 1px solid #efc1bd; border-radius: 9px; background: var(--danger-bg); color: var(--danger); }
.narrow-panel { width: min(720px, 100%); }
.compact-form { gap: 11px; }
.vertical-form { display: grid; gap: 9px; }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff; line-height: 1.7; }
.notice strong { white-space: nowrap; }
.notice-warning { border-color: #efd5a8; background: var(--warning-bg); color: #754609; }
.compact-notice { margin-bottom: 18px; padding: 11px 14px; font-size: 12px; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.team-card, .template-card { display: grid; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 5px 20px rgba(20,20,20,.025); }
.team-card header { display: grid; grid-template-columns: 45px minmax(0,1fr) auto; gap: 11px; align-items: center; }
.team-card h2, .template-card h2 { margin: 0 0 5px; font-size: 15px; }
.team-card p, .template-card p { margin: 0; color: var(--muted); line-height: 1.65; font-size: 11px; }
.team-mark { width: 43px; height: 43px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: var(--ink); color: #fff; font-weight: 700; }
.team-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; border: 1px solid var(--line); border-radius: 11px; background: var(--line); overflow: hidden; }
.team-stats > div { display: grid; gap: 4px; padding: 12px 8px; background: #fff; text-align: center; }
.team-stats strong { font-size: 20px; }
.team-stats span { color: var(--muted); font-size: 9px; }
.team-card footer, .template-card footer { display: flex; align-items: center; gap: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.team-card footer a, .template-card footer a { color: var(--info); text-decoration: none; font-size: 11px; font-weight: 700; }
.inactive-card { opacity: .65; }
.template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.template-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.template-card code { color: var(--muted); }
.template-body { min-height: 70px; padding: 13px; border-radius: 10px; background: var(--soft); color: var(--ink) !important; }
.template-card dl { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.template-card dl div { display: grid; gap: 4px; padding: 10px; border-left: 1px solid var(--line); }
.template-card dt { color: var(--muted); font-size: 9px; }
.template-card dd { margin: 0; font-size: 11px; font-weight: 700; }
.color-swatch { width: 18px; height: 18px; display: inline-block; margin-left: 7px; border-radius: 5px; background: var(--swatch); vertical-align: middle; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(290px, .7fr); gap: 18px; align-items: start; }
.action-stack { display: grid; gap: 14px; }
.action-panel { padding: 17px; margin: 0; }
.action-panel h2, .action-panel h3 { margin-bottom: 9px; }
.stacked-actions { display: grid; gap: 10px; }
.stacked-actions details { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.stacked-actions summary { cursor: pointer; font-weight: 700; font-size: 12px; }
.danger-zone { border-color: #efc1bd; }
.success-panel { border-color: #b9dfc7; background: var(--success-bg); }
.detail-list { display: grid; grid-template-columns: repeat(2, 1fr); margin: 0; }
.detail-list > div { min-height: 76px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.detail-list dt, .small-details dt { color: var(--muted); font-size: 10px; }
.detail-list dd, .small-details dd { margin: 7px 0 0; line-height: 1.65; font-weight: 700; }
.file-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 18px; }
.file-card { display: grid; gap: 7px; padding: 15px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--soft); }
.file-card span { color: var(--muted); font-size: 10px; }
.file-card a { color: var(--info); text-decoration: none; font-size: 12px; font-weight: 700; }
.file-ready { border-style: solid; border-color: #b9dfc7; background: var(--success-bg); }
.small-details { display: grid; gap: 0; margin: 0; }
.small-details > div { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.small-details > div:last-child { border-bottom: 0; }
.small-details dd { margin-top: 0; text-align: left; }

.activity-list { display: grid; }
.activity-list > div { display: grid; grid-template-columns: 12px minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 11px 18px; border-bottom: 1px solid #f0f1f2; }
.activity-list > div:last-child { border-bottom: 0; }
.activity-mark { width: 8px; height: 8px; border-radius: 50%; background: #8b8f95; }
.activity-list p { display: flex; align-items: center; gap: 8px; margin: 0; }
.activity-list p span, .activity-list time { color: var(--muted); font-size: 11px; }

.alert-list { display: grid; gap: 12px; }
.alert-card { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 14px; align-items: start; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.alert-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: var(--warning-bg); color: var(--warning); font-size: 20px; font-weight: 800; }
.alert-critical { border-color: #efc1bd; }
.alert-critical .alert-icon { background: var(--danger-bg); color: var(--danger); }
.alert-copy header { display: flex; align-items: center; gap: 9px; }
.alert-copy h2 { margin: 0; font-size: 15px; }
.alert-copy p { margin: 8px 0; color: var(--muted); line-height: 1.7; }
.alert-copy small { display: block; margin-top: 4px; }
.alert-card.resolved { opacity: .62; }

.empty-state { min-height: 220px; display: grid; place-content: center; gap: 7px; padding: 30px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); font-size: 15px; }
.empty-state p { margin: 0; line-height: 1.7; }
.wide-empty { grid-column: 1 / -1; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: #fff; }

/* Inbox */
.inbox-shell { height: calc(100vh - 124px); min-height: 650px; display: grid; direction: rtl; border: 1px solid var(--line); border-radius: 15px; background: #fff; overflow: hidden; box-shadow: var(--shadow); }
.inbox-shell-list { height: calc(100vh - 245px); grid-template-columns: 390px minmax(0,1fr); }
.inbox-shell-detail { grid-template-columns: 330px minmax(420px,1fr) 320px; }
.conversation-panel { min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: #fff; }
.conversation-panel-title { min-height: 59px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.conversation-panel-title span { color: var(--muted); font-size: 10px; }
.conversation-list { overflow-y: auto; }
.conversation-row { min-height: 102px; display: grid; grid-template-columns: 43px minmax(0,1fr) auto; gap: 10px; align-items: start; padding: 12px; border-bottom: 1px solid #eff0f1; color: inherit; text-decoration: none; transition: .14s ease; }
.conversation-row:hover { background: #fafafa; }
.conversation-row.is-active { background: #f1f2f3; box-shadow: inset -3px 0 0 var(--ink); }
.conversation-avatar { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; }
.conversation-copy { min-width: 0; display: grid; gap: 4px; }
.conversation-title { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.conversation-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-title time { color: var(--muted); font-size: 9px; }
.conversation-subline { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.conversation-subline em { margin-right: auto; color: #555; font-style: normal; }
.conversation-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #646970; font-size: 11px; }
.conversation-labels { display: flex; gap: 4px; overflow: hidden; }
.conversation-labels i { padding: 3px 6px; border-radius: 999px; background: color-mix(in srgb, var(--label-color) 12%, white); color: var(--label-color); font-size: 8px; font-style: normal; white-space: nowrap; }
.unread-badge { min-width: 21px; height: 21px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 9px; }
.chat-placeholder { display: grid; place-items: center; background: linear-gradient(145deg, #fbfbfb, #f1f2f3); text-align: center; color: var(--muted); }
.placeholder-mark { width: 70px; height: 70px; display: inline-flex; align-items: center; justify-content: center; border-radius: 20px; background: var(--ink); color: #fff; font-size: 18px; font-weight: 800; }
.chat-placeholder h2 { margin: 15px 0 5px; color: var(--ink); }
.chat-placeholder p { max-width: 420px; margin: 0; line-height: 1.7; }
.chat-panel { min-width: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; background: #f1efec; }
.chat-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fff; }
.chat-customer { display: flex; align-items: center; gap: 10px; }
.chat-avatar { width: 42px; height: 42px; }
.chat-header h1 { margin: 0 0 4px; font-size: 16px; }
.chat-header p { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 10px; }
.reveal-button { padding: 0; border: 0; background: transparent; color: var(--info); font-size: 9px; font-weight: 700; }
.chat-meta { display: flex; align-items: center; gap: 6px; }
.conversation-status { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: var(--success-bg); color: var(--success); font-size: 9px; font-weight: 700; }
.conversation-status.status-closed, .conversation-status.status-archived { background: #f0f1f2; color: #5d6470; }
.chat-context-bar { min-height: 38px; display: flex; align-items: center; gap: 18px; padding: 7px 16px; border-bottom: 1px solid var(--line); background: #fafafa; color: var(--muted); font-size: 9px; }
.chat-context-bar strong { color: #4d5157; }
.message-stream { overflow-y: auto; padding: 20px; background-image: radial-gradient(rgba(35,31,32,.045) .7px, transparent .7px); background-size: 18px 18px; }
.message-row { width: 100%; display: flex; margin: 7px 0; }
.message-inbound { justify-content: flex-start; }
.message-outbound { justify-content: flex-end; }
.message-system { justify-content: center; }
.message-bubble { max-width: min(76%, 650px); min-width: 110px; padding: 9px 11px 6px; border: 1px solid rgba(20,20,20,.08); border-radius: 13px; background: #fff; box-shadow: 0 2px 7px rgba(20,20,20,.045); }
.message-outbound .message-bubble { border-bottom-left-radius: 4px; background: #e8eee8; }
.message-inbound .message-bubble { border-bottom-right-radius: 4px; }
.message-system .message-bubble { max-width: 80%; border-style: dashed; background: rgba(255,255,255,.72); color: #62666d; font-size: 11px; text-align: center; }
.system-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 8px; font-weight: 700; }
.message-text { line-height: 1.65; overflow-wrap: anywhere; }
.message-bubble footer { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 5px; color: var(--muted); font-size: 8px; }
.message-status.status-read { color: #1674b8; }
.message-error { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; color: var(--danger); font-size: 9px; }
.composer-area { padding: 11px 14px; border-top: 1px solid var(--line); background: #fff; }
.message-composer { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: end; }
.message-composer textarea { width: 100%; min-height: 48px; max-height: 140px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px; outline: 0; }
.send-button { min-width: 85px; min-height: 48px; border: 1px solid var(--ink); border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; }
.window-note { margin: 6px 1px 0; color: var(--muted); font-size: 9px; }
.window-closed { padding: 12px; border: 1px solid #efd5a8; border-radius: 10px; background: var(--warning-bg); color: var(--warning); }
.template-composer { display: grid; gap: 10px; }
.template-composer > div p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.template-send-form { display: grid; grid-template-columns: minmax(160px,.7fr) minmax(220px,1fr) auto; gap: 8px; align-items: end; }
.template-send-form label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; }
.template-send-form textarea { min-height: 58px; resize: vertical; }
.conversation-inspector { overflow-y: auto; border-right: 1px solid var(--line); background: #fff; }
.inspector-section { padding: 15px; border-bottom: 1px solid var(--line); }
.inspector-section header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.inspector-section h2 { margin: 0; font-size: 13px; }
.inspector-section header a { color: var(--info); text-decoration: none; font-size: 9px; font-weight: 700; }
.inspector-form { display: grid; gap: 9px; }
.inspector-form label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; }
.inspector-form fieldset { margin: 0; padding: 9px; border: 1px solid var(--line); border-radius: 9px; }
.inspector-form legend { color: var(--muted); font-size: 9px; }
.inspector-form fieldset > div { display: grid; gap: 6px; }
.inspector-form fieldset label { display: flex; align-items: center; gap: 5px; }
.inspector-form fieldset input { width: auto; min-height: auto; }
.note-list { display: grid; gap: 7px; margin-top: 10px; }
.note-list article { padding: 9px; border-radius: 9px; background: var(--soft); }
.note-list p { margin: 0 0 5px; line-height: 1.55; font-size: 10px; }
.note-list small { font-size: 8px; }
.mini-list { display: grid; gap: 6px; }
.mini-list a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-size: 9px; }

.login-card { width: min(440px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 22px 60px rgba(20,20,20,.1); }
.login-card::before { content: "ALPHAPACK OPERATIONS"; display: block; margin-bottom: 25px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .28em; text-align: center; }
.login-card h1 { margin: 0 0 7px; text-align: center; }
.login-card > p { margin: 0 0 25px; color: var(--muted); line-height: 1.7; text-align: center; }
.login-card form { display: grid; gap: 8px; }
.login-card label { margin-top: 8px; font-weight: 700; font-size: 11px; }
.login-card input { width: 100%; min-height: 46px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; }
.login-card button.primary { width: 100%; margin-top: 12px; }
.error, .composer-error { padding: 11px 13px; border: 1px solid #efc1bd; border-radius: 9px; background: var(--danger-bg); color: var(--danger); }

@media (max-width: 1280px) {
  .metric-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .inbox-shell-detail { grid-template-columns: 290px minmax(390px,1fr); }
  .conversation-inspector { display: none; }
  .inbox-filter-grid { grid-template-columns: repeat(4, minmax(120px,1fr)); }
  .inbox-filter-grid input[type="search"] { grid-column: span 2; }
}
@media (max-width: 1050px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(105%); transition: transform .22s ease; box-shadow: -12px 0 35px rgba(0,0,0,.2); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close, .menu-toggle { display: inline-flex; }
  .sidebar-open .sidebar-overlay { position: fixed; inset: 0; z-index: 40; display: block; background: rgba(0,0,0,.42); }
  .app-body { width: 100%; margin-right: 0; }
  .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
  .filter-grid-5 { grid-template-columns: repeat(3, minmax(130px,1fr)); }
  .inbox-shell-list { grid-template-columns: 340px minmax(0,1fr); }
}
@media (max-width: 780px) {
  .topbar { min-height: 66px; padding: 10px 13px; }
  .user-copy, .ghost-button { display: none; }
  .container { width: min(100% - 20px, 1540px); margin: 15px auto 28px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading h1 { font-size: 26px; }
  .metric-grid-4, .metric-grid-3, .secondary-metrics, .form-grid-2, .file-grid, .card-grid, .template-grid { grid-template-columns: 1fr; }
  .dashboard-grid { gap: 0; }
  .filter-grid-5, .inbox-filter-grid, .compact-filter { grid-template-columns: 1fr; }
  .inbox-filter-grid input[type="search"] { grid-column: auto; }
  .form-panel { padding: 17px; }
  .template-card dl { grid-template-columns: repeat(2,1fr); }
  .detail-list { grid-template-columns: 1fr; }
  .inbox-shell { min-height: 540px; height: calc(100vh - 92px); border-radius: 11px; }
  .inbox-shell-list { height: auto; grid-template-columns: 1fr; }
  .inbox-shell-list .chat-placeholder { display: none; }
  .inbox-shell-detail { grid-template-columns: 1fr; }
  .inbox-shell-detail .conversation-panel { display: none; }
  .chat-context-bar { overflow-x: auto; white-space: nowrap; }
  .message-stream { padding: 14px 10px; }
  .message-bubble { max-width: 88%; }
  .template-send-form, .message-composer { grid-template-columns: 1fr; }
  .send-button { width: 100%; min-height: 42px; }
  .data-table { min-width: 760px; }
  .alert-card { grid-template-columns: 38px minmax(0,1fr); }
  .alert-card > form { grid-column: 1 / -1; }
  .flash-stack { top: 75px; left: 10px; }
  .guest-container { padding: 12px; }
  .login-card { padding: 24px 20px; }
}
