:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #152033;
  --muted: #667085;
  --line: #e4e7ec;
  --nav: #101828;
  --nav-soft: #1d2939;
  --accent: #ff6b35;
  --accent-2: #ff8a5c;
  --success: #12b76a;
  --warning: #f79009;
  --danger: #f04438;
  --info: #2e90fa;
  --radius: 16px;
  --shadow: 0 12px 34px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; font-family: Inter, Segoe UI, Arial, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--nav) 0%, #162337 100%); color: white; padding: 24px 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; margin: 2px 8px 28px; }
.logo { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #ffb199); font-weight: 900; font-size: 20px; box-shadow: 0 8px 22px rgba(255,107,53,.35); }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -.4px; }
.brand span { display: block; font-size: 11px; color: #98a2b3; margin-top: 2px; }
.nav { display: grid; gap: 7px; }
.nav button { border: 0; background: transparent; color: #d0d5dd; text-align: left; padding: 12px 14px; border-radius: 11px; display: flex; align-items: center; gap: 10px; }
.nav button:hover, .nav button.active { background: var(--nav-soft); color: white; }
.nav button.active { box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-footer { position: absolute; left: 20px; right: 20px; bottom: 20px; font-size: 11px; color: #98a2b3; line-height: 1.5; }
.main { min-width: 0; }
.topbar { min-height: 74px; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; position: sticky; top: 0; z-index: 4; }
.topbar h2 { margin: 0; font-size: 22px; }
.user-chip { display: flex; align-items: center; gap: 11px; background: #f8fafc; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px 7px 7px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #ffe8df; color: #c53c0b; display: grid; place-items: center; font-weight: 800; }
.content { padding: 28px; }
.grid { display: grid; gap: 18px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); }
.card { background: var(--panel); border: 1px solid rgba(228,231,236,.9); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h3 { margin: 0 0 15px; font-size: 16px; }
.stat { position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; width: 80px; height: 80px; border-radius: 50%; right: -24px; top: -24px; background: rgba(255,107,53,.08); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -1px; }
.stat-note { font-size: 12px; color: var(--muted); margin-top: 5px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar-left, .toolbar-right { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.btn { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 700; transition: .16s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; box-shadow: 0 7px 16px rgba(255,107,53,.25); }
.btn-dark { background: var(--nav); color: white; }
.btn-ghost { background: #f2f4f7; color: #344054; }
.btn-danger { background: #fee4e2; color: #b42318; }
.btn-success { background: #d1fadf; color: #067647; }
.input, select, textarea { width: 100%; border: 1px solid #d0d5dd; background: white; border-radius: 10px; padding: 10px 12px; outline: none; }
.input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,107,53,.12); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: #344054; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; white-space: nowrap; }
th { background: #f8fafc; color: #475467; font-weight: 800; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; }
.badge.success { background: #d1fadf; color: #067647; }
.badge.warning { background: #fef0c7; color: #b54708; }
.badge.danger { background: #fee4e2; color: #b42318; }
.badge.info { background: #d1e9ff; color: #175cd3; }
.section { display: none; }
.section.active { display: block; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.55); z-index: 20; display: grid; place-items: center; padding: 20px; }
.modal { width: min(850px, 100%); max-height: 92vh; overflow: auto; background: white; border-radius: 20px; box-shadow: 0 32px 80px rgba(0,0,0,.25); padding: 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { margin: 0; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 9px; background: #f2f4f7; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, .8fr) minmax(520px, 1.2fr); }
.login-panel { background: white; display: grid; place-items: center; padding: 40px; }
.login-card { width: min(420px, 100%); }
.login-card h1 { margin: 18px 0 8px; font-size: 34px; letter-spacing: -1px; }
.login-card p { color: var(--muted); margin: 0 0 28px; line-height: 1.5; }
.login-card form { display: grid; gap: 15px; }
.login-hero { background: radial-gradient(circle at 20% 15%, rgba(255,107,53,.3), transparent 28%), linear-gradient(135deg, #101828, #23395d); color: white; padding: 64px; display: flex; flex-direction: column; justify-content: flex-end; }
.login-hero h2 { font-size: clamp(36px, 5vw, 68px); margin: 0 0 14px; letter-spacing: -2px; max-width: 780px; }
.login-hero p { color: #d0d5dd; max-width: 640px; font-size: 18px; line-height: 1.55; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; background: #101828; color: white; border-radius: 12px; padding: 13px 17px; box-shadow: var(--shadow); max-width: 420px; }
.toast.error { background: #b42318; }
.chat-layout { display: grid; grid-template-columns: 250px 1fr; min-height: 560px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.chat-users { background: #f8fafc; border-right: 1px solid var(--line); padding: 12px; }
.chat-user { width: 100%; text-align: left; border: 0; background: transparent; padding: 11px; border-radius: 9px; }
.chat-user:hover, .chat-user.active { background: white; box-shadow: 0 3px 10px rgba(16,24,40,.06); }
.chat-main { display: grid; grid-template-rows: 1fr auto; min-width: 0; }
.chat-messages { padding: 18px; overflow-y: auto; max-height: 500px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 72%; padding: 10px 13px; border-radius: 14px; background: #f2f4f7; }
.bubble.mine { align-self: flex-end; background: #ffe8df; }
.bubble small { display: block; color: var(--muted); margin-top: 5px; }
.chat-compose { border-top: 1px solid var(--line); padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.legal-note { border-left: 4px solid var(--warning); background: #fffaeb; border-radius: 10px; padding: 12px 14px; color: #7a2e0e; font-size: 13px; line-height: 1.5; }
@media (max-width: 1100px) {
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; padding: 13px; }
  .brand { margin: 0 0 12px; }
  .nav { display: flex; overflow-x: auto; }
  .nav button { white-space: nowrap; }
  .sidebar-footer { display: none; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .grid.stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-users { border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; }
}
