:root {
  --bg: #edf1f7;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eef2f8;
  --border: #e2e8f2;
  --border-strong: #c3cede;
  --text: #16233a;
  --text-muted: #5b6b84;
  --text-soft: #8ea0b8;
  --link: #1d6fd1;
  --primary: #f97316;
  --primary-deep: #ea580c;
  --primary-ink: #9a3412;
  --primary-hover: #ea580c;
  --primary-soft: #fff4ea;
  --primary-ring: rgba(249, 115, 22, 0.22);
  --success: #16a34a;
  --success-deep: #15803d;
  --success-soft: #ecfdf3;
  --danger: #dc2626;
  --danger-deep: #b91c1c;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --sidebar-bg: #0c1526;
  --sidebar-bg-2: #14213c;
  --sidebar-text: #93a1bb;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(249, 115, 22, 0.16);
  --header-bg: rgba(255, 255, 255, 0.9);
  --header-text: #16233a;
  --icon-blue: #2563eb;
  --icon-navy: #334155;
  --icon-gray: #7f8c8d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 18px -6px rgba(16, 24, 40, 0.14);
  --shadow-lg: 0 18px 44px -16px rgba(16, 24, 40, 0.28);
  --sidebar-width: 264px;
  --rail-width: 280px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(249, 115, 22, 0.06), transparent 60%),
    radial-gradient(1000px 600px at -10% 0%, rgba(37, 99, 235, 0.05), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(249, 115, 22, 0.25); }

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

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
code {
  font-family: var(--mono); font-size: 0.87em;
  background: var(--surface-3); padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border); color: #334155;
}

.icon { vertical-align: middle; display: inline-block; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; line-height: 1;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); box-shadow: var(--shadow); }
.btn-primary {
  background: linear-gradient(180deg, #fb7f2b, var(--primary-deep));
  color: #fff; border-color: #d14e0b;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}
.btn-primary:hover { background: linear-gradient(180deg, #f97316, #d14e0b); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); border-color: #a9b8d0; }
.btn-danger { background: linear-gradient(180deg, #ef4444, var(--danger-deep)); color: #fff; border-color: #991b1b; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }

.inline-form { display: inline; }

.btn[aria-disabled="true"] { opacity: 0.65; cursor: wait; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 120; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.field-error { color: var(--danger-deep); font-size: 13px; margin: 6px 0 0; }
[aria-invalid="true"] { border-color: var(--danger); }
[id] { scroll-margin-top: 120px; }

/* ---------- Auth shell ---------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(37, 99, 235, 0.35), transparent 60%),
    radial-gradient(800px 600px at 85% 85%, rgba(249, 115, 22, 0.4), transparent 55%),
    radial-gradient(600px 400px at 70% 15%, rgba(168, 85, 247, 0.22), transparent 60%),
    linear-gradient(135deg, #0b1220 0%, #16233f 55%, #3a2b1c 100%);
  padding: 24px;
}
.auth-wrap { width: 100%; max-width: 410px; }
.auth-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 18px; padding: 34px 34px 30px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(16, 24, 40, 0.06);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand-mark-lg { color: var(--primary); filter: drop-shadow(0 2px 6px rgba(249, 115, 22, 0.45)); }
.auth-brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.auth-title { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); margin: 0 0 22px; font-size: 13.5px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 13px; color: var(--text-muted); }
.auth-center { text-align: center; }
.error-code { font-size: 56px; font-weight: 800; letter-spacing: -0.03em; color: var(--primary); margin-bottom: 8px; }
.error-trace {
  text-align: left; font-family: var(--mono); font-size: 12px;
  background: var(--surface-2); padding: 14px; border-radius: 10px;
  overflow: auto; max-height: 300px; white-space: pre-wrap; margin: 16px 0;
  border: 1px solid var(--border);
}

/* ---------- Shell layout ---------- */
.shell { display: flex; min-height: 100vh; }

/* ---- Top header bar ---- */
.topbar {
  display: flex; align-items: center; gap: 0;
  height: 60px; background: var(--header-bg); color: var(--header-text);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(16, 24, 40, 0.06);
  position: sticky; top: 0; z-index: 60;
}
.topbar-brand {
  height: 60px; min-width: 224px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px; padding: 0 18px;
  background: transparent; color: var(--text);
}
.topbar-brand .brand-mark { color: var(--primary); filter: drop-shadow(0 1px 4px rgba(249, 115, 22, 0.4)); }
.topbar-brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.topbar-menu { display: none; background: none; border: 0; cursor: pointer; color: var(--text); padding: 0 14px; height: 60px; border-radius: 8px; }
.topbar-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; padding: 0 4px 0 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; height: 60px; padding-right: 14px; }
.topbar-actions .topbar-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); cursor: pointer; position: relative;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.topbar-actions .topbar-icon:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.topbar-actions .topbar-icon.logout-link { width: auto; padding: 0 14px; gap: 8px; font-size: 13px; font-weight: 600; text-decoration: none; }
.user-menu { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 4px 0 12px; margin-left: 4px; border-left: 1px solid var(--border); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #fb923c, #ea580c);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 4px; }
.sidebar-light {
  background: linear-gradient(180deg, #ffffff 0%, #f4f7fc 100%); color: #3a4a5e;
  border-right: 1px solid var(--border);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-light .sidebar-brand { border-bottom-color: var(--border); }
.brand-mark { color: var(--primary); }
.brand-name { font-size: 13.5px; font-weight: 700; letter-spacing: 0.02em; color: #fff; }
.sidebar-light .brand-name { color: #1e293b; }
.sidebar-close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; display: none; border-radius: 8px; padding: 4px; }

.sidebar-search { padding: 14px 14px 6px; position: relative; }
.sidebar-search .search-icon { position: absolute; left: 26px; top: 50%; transform: translateY(-32%); color: var(--text-soft); }
.sidebar-search input {
  width: 100%; padding: 9px 10px 9px 36px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.07);
  color: #fff; font-size: 13px; transition: border-color 0.15s, box-shadow 0.15s;
}
.sidebar-light .sidebar-search input { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.sidebar-search input::placeholder { color: var(--text-soft); }
.sidebar-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

.sidebar-nav { flex: 1; padding: 10px; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, 0.07); font-size: 11px; color: var(--text-soft); }
.sidebar-light .sidebar-footer { border-top-color: var(--border); }
.sidebar-env {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
}
.sidebar-light .sidebar-env { background: var(--surface-3); border-color: var(--border); color: var(--text-muted); }

/* ---------- Nav ---------- */
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav li { margin: 0; }
.nav-group { position: relative; }
.nav-section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-soft); padding: 12px 12px 4px;
}

.nav-link, .nav-group-toggle {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 12px; border-radius: 10px;
  color: inherit; background: none; border: 0; cursor: pointer;
  font-size: 13.5px; font-weight: 500; text-align: left;
  position: relative; transition: background 0.13s, color 0.13s;
}
.nav-link:hover, .nav-group-toggle:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-light .nav-link:hover, .sidebar-light .nav-group-toggle:hover { background: #e8eef7; color: #1e293b; }
.nav-link.is-active, .nav-group.is-active > .nav-group-toggle {
  background: linear-gradient(90deg, var(--sidebar-active), rgba(249, 115, 22, 0.07));
  color: #fff; font-weight: 600;
}
.nav-link.is-active::before, .nav-group.is-active > .nav-group-toggle::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  background: linear-gradient(180deg, #fdba74, var(--primary));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.8);
}
.sidebar-light .nav-link.is-active, .sidebar-light .nav-group.is-active > .nav-group-toggle {
  background: linear-gradient(90deg, #fff1e6, #fff8f1);
  color: var(--primary-ink);
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.25);
}
.sidebar-light .nav-link.is-active::before, .sidebar-light .nav-group.is-active > .nav-group-toggle::before {
  box-shadow: 0 0 6px rgba(249, 115, 22, 0.5);
}
.nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 19px; height: 19px; flex-shrink: 0; color: var(--text-soft); }
.nav-icon .icon { width: 100%; height: 100%; }
.sidebar-light .nav-icon { color: #8296b1; }
.nav-link.is-active .nav-icon, .nav-group.is-active > .nav-group-toggle .nav-icon { color: #fdba74; }
.sidebar-light .nav-link.is-active .nav-icon { color: var(--primary); }
.nav-label { flex: 1; }
.nav-chevron { display: inline-flex; transition: transform 0.15s; color: var(--text-soft); }
.nav-group.is-open .nav-chevron { transform: rotate(180deg); }

.nav-children { list-style: none; margin: 2px 0 6px; padding: 0 0 0 15px; display: none; }
.nav-group.is-open .nav-children { display: block; }
.nav-child {
  display: block; padding: 7px 10px 7px 31px; border-radius: 8px;
  color: inherit; font-size: 13px; border-left: 2px solid transparent;
}
.nav-child:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-light .nav-child:hover { background: #e8eef7; color: #1e293b; }
.nav-child.is-active { border-left-color: var(--primary); color: #fff; background: rgba(249, 115, 22, 0.18); font-weight: 600; }
.sidebar-light .nav-child.is-active { color: var(--primary-ink); background: #fff1e6; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content-wrap { flex: 1; display: flex; gap: 0; max-width: 1440px; width: 100%; margin: 0 auto; }
.content { flex: 1; min-width: 0; padding: 26px 28px 40px; }

/* ----- Breadcrumbs ribbon (sub-header) ----- */
.breadcrumbs {
  font-size: 12.5px; background: rgba(255, 255, 255, 0.75);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 9px 28px;
}
.breadcrumbs ol { list-style: none; display: flex; margin: 0 auto; max-width: 1440px; padding: 0; gap: 8px; }
.breadcrumbs li { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.breadcrumbs li + li::before { content: "/"; color: var(--text-soft); }
.breadcrumbs a { color: var(--text-muted); font-weight: 500; }
.breadcrumbs a:hover { color: var(--primary-deep); }
.breadcrumbs li:last-child { color: var(--text); font-weight: 600; }

.page-head { margin-bottom: 18px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin: 26px 0 12px; }

/* ---------- Flash ---------- */
.flash {
  position: relative; padding: 12px 16px 12px 18px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px;
  background: var(--surface); box-shadow: var(--shadow);
  overflow: hidden;
}
.flash::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--text-soft); }
.flash-success { background: var(--success-soft); border-color: #bbe6c3; color: #14532d; }
.flash-success::before { background: linear-gradient(180deg, #22c55e, var(--success-deep)); }
.flash-error { background: var(--danger-soft); border-color: #f3c1c0; color: #7f1d1d; }
.flash-error::before { background: linear-gradient(180deg, #ef4444, var(--danger-deep)); }
.flash-warning { background: var(--warning-soft); border-color: #f3d391; color: #92600a; }
.flash-warning::before { background: linear-gradient(180deg, #f59e0b, var(--warning)); }
.flash-list { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat {
  background: linear-gradient(180deg, #ffffff, #fafcff);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--primary), #fbbf24); opacity: 0.85;
}
.stat-value { display: block; font-size: 27px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-label { display: block; color: var(--text-muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 3px; }

/* ---------- Cards ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.15s;
}
.card-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.card-value { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin-top: 5px; font-variant-numeric: tabular-nums; }

/* ---- Progress bars ---- */
.bar { height: 7px; background: #e5eaf2; border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #fb923c, var(--primary-deep)); border-radius: 4px; transition: width 0.4s ease; }
.bar-fill.green { background: linear-gradient(90deg, #22c55e, var(--success-deep)); }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: auto; box-shadow: var(--shadow-md);
}
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th {
  background: linear-gradient(180deg, #f8fafd, #eef2f8);
  font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  position: sticky; top: 0; white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: #f6f9fe; }
.table .empty { text-align: center; color: var(--text-muted); padding: 30px; }
.table-info th { width: 230px; background: var(--surface-2); font-weight: 600; color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.actions { white-space: nowrap; text-align: right; }
.actions .btn { margin-left: 6px; }
.text-muted { color: var(--text-muted); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.inherit-link { color: inherit; text-decoration: none; }
.row-unread { font-weight: 600; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 22px; box-shadow: var(--shadow-md); overflow: hidden; }
.panel-header {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fbfcfe, var(--surface));
}
.panel-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }

/* ---------- Badges & status ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text-muted);
}
.badge-warning { background: var(--warning-soft); border-color: #f3d391; color: #92600a; }
.badge-primary { background: var(--primary-soft); border-color: #fdba74; color: var(--primary-ink); }
.badge-danger { background: var(--danger-soft); border-color: #f3c1c0; color: #7f1d1d; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-soft);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}
.status-active { color: var(--success-deep); }
.status-active::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.status-disabled { color: var(--text-muted); }
.status-disabled::before { background: #94a3b8; }
.status-failed { color: var(--danger-deep); }
.status-failed::before { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18); }
.status-error { color: var(--danger-deep); }
.status-error::before { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18); }
.status-warn { color: #92600a; }
.status-warn::before { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2); }
.row-muted { opacity: .65; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; align-items: flex-end; background: var(--surface-2);
}
.filter-bar .input { min-width: 180px; }

/* ---------- Forms ---------- */
.form-stack { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text); }
.input {
  padding: 9px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover { border-color: #9db1cc; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.input:disabled { background: var(--surface-2); color: var(--text-muted); }
select.input {
  background: var(--surface);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235b6b84' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}
textarea.input { line-height: 1.55; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary-deep); width: 15px; height: 15px; }
.field-help { margin: 0; font-size: 12px; color: var(--text-muted); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0; background: var(--surface-2); }
.fieldset-legend { font-size: 13px; font-weight: 700; padding: 2px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; }

/* ---------- Feature grid (customer, cPanel-style) ---------- */
.welcome { margin-bottom: 18px; }
.welcome-title { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.welcome-sub { color: var(--text-muted); margin: 3px 0 0; font-size: 13.5px; }

.fn-search { position: relative; margin: 0 0 22px; max-width: 720px; }
.fn-search input {
  width: 100%; height: 50px; padding: 0 46px 0 16px;
  font-size: 15px; border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fn-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring), var(--shadow-md); }
.fn-search .search-icon { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--text-soft); }
.fn-search input::placeholder { color: var(--text-soft); }

.fn-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow-md); overflow: hidden; }
.fn-section-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #fbfcfe, var(--surface)); }
.fn-section-title { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); }

.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.feature {
  display: flex; align-items: center; gap: 13px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 16px 18px; min-height: 70px;
  color: var(--text); text-decoration: none; background: var(--surface);
  transition: background 0.14s, box-shadow 0.14s;
  position: relative;
}
.feature:hover { background: #fff8f1; text-decoration: none; box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.35); z-index: 1; }
.feature-icon {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fff1e2, #ffe3c7);
  color: var(--primary-deep);
  border: 1px solid rgba(249, 115, 22, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.feature:hover .feature-icon {
  background: linear-gradient(135deg, #fb923c, var(--primary-deep));
  color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.4);
}
.feature-label { font-size: 14px; color: var(--text); font-weight: 600; letter-spacing: -0.005em; }
.feature:hover .feature-label { text-decoration: none; color: var(--primary-ink); }
.feature-links { display: flex; flex-direction: column; gap: 3px; font-size: 13px; margin-left: 55px; padding-bottom: 10px; }
.feature-links a { color: var(--link); }

/* ---------- Customer dashboard grid (content + info rail) ---------- */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.dashboard-grid > * { min-width: 0; }
.dashboard-grid .rail { width: auto; padding: 0; }
/* Info / stats rail (right column) ---------- */
.rail { width: var(--rail-width); flex-shrink: 0; padding: 26px 18px 26px 0; }
.rail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow-md); overflow: hidden; }
.rail-card-header { padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px; font-weight: 650; background: linear-gradient(180deg, #fbfcfe, var(--surface)); }
.rail-row { padding: 11px 18px; border-bottom: 1px solid #eef1f6; }
.rail-row:last-child { border-bottom: 0; }
.rail-row-label { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.rail-row-value { font-size: 13px; color: var(--text); margin-top: 2px; word-break: break-all; font-variant-numeric: tabular-nums; }
.rail-stat { padding: 11px 18px; border-bottom: 1px solid #eef1f6; }
.rail-stat:last-child { border-bottom: 0; }

/* ---------- Webmail message ---------- */
.webmail-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; align-items: start; }
.webmail-shell > * { min-width: 0; }
.folder-list { list-style: none; margin: 0; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.folder-link { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 8px; color: inherit; text-decoration: none; font-size: 13.5px; font-weight: 500; }
.folder-link:hover { background: var(--surface-3); text-decoration: none; }
.folder-link.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.3); }
.message-meta { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.message-meta > div { margin-bottom: 4px; }
.message-meta > div:last-child { margin-bottom: 0; }
.message-body { padding: 18px; }
.message-text { white-space: pre-wrap; word-break: break-word; font-family: inherit; }
.message-attachments { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.attachment-list { margin: 0; padding: 0; list-style: none; }
.attachment-list li { padding: 4px 0; }

/* ---------- File manager ---------- */
.fm-archive { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.fm-archive > summary { list-style: none; cursor: pointer; }
.fm-archive > summary::-webkit-details-marker { display: none; }
.fm-archive .details-body {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 14px 16px; margin-top: 8px;
}
.inline-details { position: relative; display: inline-block; }
.inline-details > summary { list-style: none; cursor: pointer; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details .details-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 250px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 12px 14px;
}
.inline-details .details-body hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.fm-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

/* ---------- Layout helpers ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .feature-grid { grid-template-columns: repeat(3, 1fr); }
  .rail { display: none; }
  /* Dashboard must collapse to one column when the rail hides — the
     two-column grid would otherwise leave a 280px empty track that
     squeezes content (and, under a stale inline style, overflows). */
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 90; visibility: hidden; transform: translateX(-100%); transition: transform 0.2s; overscroll-behavior: contain; height: 100vh; }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .sidebar { visibility: visible; transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); z-index: 80; }
  /* Mobile topbar: the menu button doubles as the brand slot (44px touch
     target). The desktop brand block is hidden so nothing overlaps, and the
     user name collapses early — at 900px the avatar + name + logout no
     longer fit beside the title/actions. */
  .topbar-menu { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; }
  .topbar-brand { display: none; }
  .user-name { display: none; }
}
/* Impersonation banner: wraps to two lines on narrow screens instead of
   forcing the topbar/shell into horizontal overflow (the banner sits above
   the sidebar+content flex row). */
.masq-banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.masq-banner .inline-form { margin-left: 12px; }
@media (max-width: 700px) {
  .masq-banner .inline-form { margin-left: 0; flex-basis: 100%; }
}
@media (max-width: 700px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .webmail-shell { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 18px 16px 32px; }
  .topbar { padding: 0; }
  .topbar-actions .topbar-icon { display: none; }
  .topbar-brand { width: auto; }
  .topbar-title { display: none; }
  .breadcrumbs ol, .panel-header, .form-actions { flex-wrap: wrap; }
  .btn, .topbar-menu, .sidebar-close { min-height: 44px; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 460px) {
  .feature-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .nav-chevron, .btn, .feature, .bar-fill { transition: none; }
}

/* Interaction/numeric consistency (Web Interface Guidelines) */
html { -webkit-tap-highlight-color: transparent; }
a, .btn, .topbar-icon, .nav-link, .sidebar-close, .table button, .table a { touch-action: manipulation; }
.table td.num, .stat-value, .bar-label, .code, .mono { font-variant-numeric: tabular-nums; }

/* Notifications bell */
.notif { position: relative; display: inline-flex; }
.notif-toggle { position: relative; }
.notif-badge { position: absolute; top: 4px; right: 2px; transform: translate(50%, -50%); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger, #dc2626); color: #fff; font-size: 10px; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums; }
.notif-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; max-width: 90vw; background: var(--surface, #fff); border: 1px solid var(--border, #d9dce1); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.14); z-index: 120; overflow: hidden; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--border, #e4e6ea); }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.notif-item { border-bottom: 1px solid var(--border, #eef0f3); }
.notif-item.is-read { opacity: .62; }
.notif-item a { display: block; padding: 10px 12px; color: inherit; }
.notif-item a:hover { background: var(--surface-soft, #f5f6f8); }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-body { color: var(--text-soft, #6b7280); font-size: 12px; margin-top: 2px; }
.notif-meta { color: var(--text-faint, #9ca3af); font-size: 11px; margin-top: 4px; }
.notif-empty { margin: 0; padding: 16px; text-align: center; color: var(--text-soft, #6b7280); }
