:root {
  --blue: #11a5e5;
  --blue-dark: #0875ad;
  --navy: #0b3552;
  --navy-soft: #174d6d;
  --orange: #de7a2b;
  --mint: #23b88b;
  --ink: #203149;
  --muted: #6f7f92;
  --line: #e7edf2;
  --surface: #ffffff;
  --canvas: #f5f8fa;
  --shadow: 0 18px 44px rgba(23, 63, 88, 0.09);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; display: flex; flex-direction: column; padding: 28px 18px 22px; color: white; background: linear-gradient(180deg, #0a3d5c 0%, #082c45 100%); z-index: 10; }
.sidebar::after { content: ""; position: absolute; width: 230px; height: 230px; border: 48px solid rgba(23, 173, 225, .08); border-radius: 50%; left: -120px; bottom: 70px; }
.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-lockup img { width: 38px; height: 38px; border-radius: 11px; object-fit: cover; }
.brand-lockup strong { color: white; font-size: 21px; letter-spacing: -.035em; white-space: nowrap; }
.sidebar-logo { margin: 0 10px 38px; position: relative; z-index: 1; }
.sidebar nav { display: grid; gap: 8px; position: relative; z-index: 1; }
.nav-item { display: flex; align-items: center; gap: 13px; width: 100%; border: 0; color: #c9d8e1; background: transparent; border-radius: 12px; padding: 13px 15px; text-align: left; font-weight: 650; }
.nav-item span { display: grid; place-items: center; width: 25px; font-size: 20px; color: #7fcce9; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.11); }
.sidebar-foot { margin-top: auto; display: grid; gap: 14px; position: relative; z-index: 1; font-size: 13px; color: #bdd0dc; }
.sidebar-foot div { display: flex; gap: 9px; align-items: center; padding: 0 10px; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #43d5a3; box-shadow: 0 0 0 5px rgba(67,213,163,.12); }
.sidebar-foot button { border: 1px solid rgba(255,255,255,.18); border-radius: 10px; color: white; background: rgba(255,255,255,.06); padding: 10px 14px; width: 100%; }
.signed-user { color: #e4eef4; font-weight: 700; }

.app-main { margin-left: 248px; min-height: 100vh; padding: 34px 42px 56px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 30px; }
.topbar h1 { margin: 5px 0 0; font-size: clamp(26px, 3vw, 38px); color: var(--navy); letter-spacing: -.04em; }
.eyebrow { color: var(--blue-dark); text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 800; }
.top-actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 14px; }
.top-actions button, .text-button { border: 0; color: var(--blue-dark); background: #e7f5fb; border-radius: 10px; padding: 10px 14px; font-weight: 700; }
.logout-top { display: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.metric { min-height: 150px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { color: var(--navy); font-size: 42px; margin: 12px 0 4px; letter-spacing: -.05em; }
.metric small { color: #91a0ad; margin-top: auto; }
.metric.accent { color: white; border: 0; background: linear-gradient(145deg, #119cd9, #0b5c89); }
.metric.accent span, .metric.accent strong, .metric.accent small { color: white; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .75fr); gap: 20px; margin-top: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.panel h2, .section-intro h2 { margin: 5px 0 7px; color: var(--navy); letter-spacing: -.025em; }
.panel p, .section-intro p { color: var(--muted); line-height: 1.6; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 15px; }

.call-list { display: grid; }
.call-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 13px; padding: 14px 2px; border-top: 1px solid var(--line); }
.call-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--blue-dark); background: #e8f7fc; font-size: 18px; }
.call-icon.out { color: #b96219; background: #fff1e4; }
.call-row strong { display: block; font-size: 14px; }
.call-row small { color: var(--muted); }
.call-state { font-size: 12px; padding: 6px 9px; border-radius: 999px; color: #277a61; background: #e5f7f1; }
.call-state.missed { color: #aa533f; background: #fff0ec; }

.callback-panel { background: linear-gradient(180deg, #ffffff, #f1f9fc); }
label { display: grid; gap: 7px; color: #46566a; font-size: 13px; font-weight: 700; margin-top: 15px; }
input, select { width: 100%; border: 1px solid #d8e2ea; border-radius: 11px; color: var(--ink); background: white; padding: 12px 13px; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(17,165,229,.12); }
form button, .integration-card button { width: 100%; border: 0; border-radius: 11px; padding: 12px 15px; margin-top: 18px; color: white; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); font-weight: 800; }

.view { display: none; }
.view.active { display: block; animation: reveal .25s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
.section-intro { margin-bottom: 22px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; text-align: left; padding: 12px; border-bottom: 1px solid var(--line); }
td { padding: 15px 12px; border-bottom: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
.privacy-badge { color: #277a61; background: #e6f7f1; border-radius: 999px; padding: 7px 11px; font-size: 12px; font-weight: 800; }

.extension-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.extension-card { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.extension-top { display: flex; justify-content: space-between; align-items: center; }
.extension-number { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 15px; color: white; background: linear-gradient(145deg, var(--blue), var(--blue-dark)); font-weight: 850; }
.extension-card h3 { margin: 17px 0 5px; color: var(--navy); }
.extension-card p { margin: 0; color: var(--muted); font-size: 13px; }
.status-tag { font-size: 11px; font-weight: 800; border-radius: 999px; padding: 6px 9px; color: #9b533b; background: #fff0e9; }
.status-tag.online { color: #277a61; background: #e5f7f1; }

.switchboard-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; }
.greeting-card { grid-row: span 2; background: linear-gradient(145deg, #0b4263, #0a2f49); color: white; }
.greeting-card h2, .greeting-card .eyebrow { color: white; }
.greeting-card p { color: #c7dce8; }
.greeting-card audio { width: 100%; margin: 22px 0; }
.audio-meta { display: grid; gap: 8px; color: #c7dce8; font-size: 12px; }
.route { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); }
.route b { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--blue-dark); background: #e7f6fb; }
.route strong, .route small { display: block; }
.route small { color: var(--muted); margin-top: 3px; }

.demo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.device-card { display: flex; flex-direction: column; min-height: 390px; }
.device-heading { display: flex; align-items: center; gap: 14px; }
.device-heading h2 { margin: 3px 0 0; }
.device-icon { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 48px; border-radius: 15px; color: white; background: linear-gradient(145deg, var(--blue), var(--blue-dark)); font-size: 24px; font-weight: 800; }
.device-icon.speaker { background: linear-gradient(145deg, var(--orange), #bb5e1b); }
.level-meter { height: 16px; margin: 24px 0 14px; overflow: hidden; border-radius: 999px; background: #eaf0f4; box-shadow: inset 0 1px 2px rgba(10,53,82,.08); }
.level-meter span { display: block; width: 3%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), #f1b646, #e06144); transition: width .08s linear; }
.device-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.device-status i { width: 9px; height: 9px; border-radius: 50%; background: #aebac4; box-shadow: 0 0 0 4px rgba(174,186,196,.14); }
.device-status.ok { color: #28765f; }
.device-status.ok i { background: var(--mint); box-shadow: 0 0 0 4px rgba(35,184,139,.14); }
.device-status.error { color: #a94e3b; }
.device-status.error i { background: #df7057; box-shadow: 0 0 0 4px rgba(223,112,87,.14); }
.demo-button { width: 100%; border: 0; border-radius: 11px; padding: 12px 15px; margin-top: auto; color: white; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); font-weight: 800; }
.demo-button.testing { color: var(--blue-dark); background: #e7f5fb; }
.speaker-visual { height: 42px; display: flex; align-items: center; justify-content: center; gap: 6px; margin: 11px 0 12px; }
.speaker-visual span { width: 6px; height: 10px; border-radius: 99px; background: #d5e0e7; transition: height .18s ease, background .18s ease; }
.speaker-visual.playing span { background: var(--orange); animation: sound-bar .6s ease-in-out infinite alternate; }
.speaker-visual.playing span:nth-child(2), .speaker-visual.playing span:nth-child(4) { animation-delay: -.2s; }
.speaker-visual.playing span:nth-child(3) { animation-delay: -.4s; }
@keyframes sound-bar { to { height: 38px; } }
.demo-call-card { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, .65fr); gap: 28px; align-items: center; overflow: hidden; background: linear-gradient(135deg, #0b4263, #092e47); color: white; }
.demo-call-card h2 { color: white; font-size: 29px; }
.demo-call-card p { color: #c7dce8; max-width: 650px; }
.demo-call-card .eyebrow { color: #86d6f2; }
.demo-safety { display: inline-flex; align-items: center; gap: 8px; margin-top: 9px; color: #bfe9dc; font-size: 13px; font-weight: 750; }
.demo-safety span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(35,184,139,.2); }
.demo-phone { display: grid; justify-items: center; padding: 25px; border: 1px solid rgba(255,255,255,.14); border-radius: 22px; background: rgba(255,255,255,.08); text-align: center; }
.demo-phone::before { content: "☎"; display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 15px; border-radius: 50%; color: white; background: var(--mint); font-size: 25px; }
.demo-call-label { color: #a9c8d9; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.demo-phone strong { margin: 7px 0; font-size: 20px; }
.demo-phone small { color: #b9d0dc; font-variant-numeric: tabular-nums; }
.demo-phone button { width: 100%; border: 0; border-radius: 11px; margin-top: 20px; padding: 12px 15px; color: #08324d; background: white; font-weight: 850; }
.demo-phone.ringing { animation: phone-ring .65s ease-in-out infinite alternate; }
.demo-phone.connected::before { background: var(--blue); }
.demo-phone.connected button { color: white; background: #d8624b; }
@keyframes phone-ring { to { transform: translateY(-3px); box-shadow: 0 14px 35px rgba(0,0,0,.18); } }

.users-layout { display: grid; grid-template-columns: minmax(280px, .62fr) minmax(0, 1.38fr); gap: 20px; align-items: start; }
.user-form-card { background: linear-gradient(180deg, #ffffff, #f1f9fc); }
.user-form-card h2 { margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.users-panel { min-width: 0; }
.user-cell strong, .user-cell small { display: block; }
.user-cell small { color: var(--muted); margin-top: 3px; }
.role-badge, .active-badge { display: inline-flex; border-radius: 999px; padding: 6px 9px; font-size: 11px; font-weight: 800; }
.role-badge { color: var(--blue-dark); background: #e8f7fc; }
.role-badge.admin { color: #9c5a21; background: #fff1e4; }
.active-badge { color: #277a61; background: #e5f7f1; }
.active-badge.off { color: #9b533b; background: #fff0e9; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.user-actions button { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; color: var(--blue-dark); background: white; font-size: 11px; font-weight: 800; }
.user-actions button.danger { color: #a54735; }
.password-dialog { width: min(440px, calc(100% - 32px)); border: 0; border-radius: 20px; padding: 28px; color: var(--ink); box-shadow: 0 30px 80px rgba(0,25,40,.28); }
.password-dialog::backdrop { background: rgba(4,25,39,.55); backdrop-filter: blur(3px); }
.password-dialog h2 { margin: 6px 0; color: var(--navy); }
.password-dialog p { margin: 0 0 8px; color: var(--muted); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.dialog-actions button { border: 0; border-radius: 10px; padding: 11px; color: white; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); font-weight: 800; }
.dialog-actions .secondary-button { color: var(--ink); background: #edf3f6; }

.alert { margin: -12px 0 20px; padding: 13px 16px; border-radius: 12px; color: #256b57; background: #e5f7f1; border: 1px solid #c7eddf; }
.alert.error { color: #9b4636; background: #fff0ec; border-color: #f4d2c8; }
.hidden, .login-error { display: none; }
.loading-block { color: var(--muted); padding: 30px 0; }
.empty-state { color: var(--muted); padding: 30px 0; text-align: center; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: radial-gradient(circle at 15% 15%, rgba(25,174,228,.22), transparent 32%), linear-gradient(135deg, #082f49 0 48%, #f5f8fa 48%); }
.login-shell { width: min(1040px, 100%); display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 60px; }
.login-brand { color: white; padding: 35px; }
.login-lockup { margin-bottom: 50px; }
.login-lockup img { width: 56px; height: 56px; border-radius: 16px; }
.login-lockup strong { font-size: 32px; }
.login-brand .eyebrow { color: #8fdbf5; }
.login-brand h1 { font-size: clamp(38px, 5vw, 62px); line-height: 1.02; letter-spacing: -.05em; margin: 14px 0 20px; }
.login-brand p { color: #c8dce7; font-size: 18px; line-height: 1.6; max-width: 520px; }
.login-card { padding: 42px; border-radius: 25px; background: white; box-shadow: 0 30px 70px rgba(0,25,40,.2); }
.login-card h2 { color: var(--navy); font-size: 32px; margin: 25px 0 6px; }
.login-card > p { color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; color: var(--blue-dark); background: #e9f7fc; padding: 8px 11px; font-size: 12px; font-weight: 800; }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); }
.login-error.visible { display: block; color: #ad4d39; font-size: 13px; margin: 12px 0 0; }

@media (max-width: 980px) {
  .sidebar { width: 82px; padding-inline: 12px; }
  .sidebar-logo { margin-inline: 4px; }
  .sidebar-logo strong { display: none; }
  .nav-item { justify-content: center; }
  .nav-item span { width: auto; }
  .nav-item:not(.active) { color: #a9bfcb; }
  .nav-item { font-size: 0; }
  .nav-item span { font-size: 21px; }
  .sidebar-foot span, .sidebar-foot form { display: none; }
  .app-main { margin-left: 82px; padding: 28px 24px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .switchboard-grid, .users-layout, .demo-grid { grid-template-columns: 1fr; }
  .greeting-card { grid-row: auto; }
  .demo-call-card { grid-column: auto; grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .sidebar { position: fixed; inset: auto 0 0 0; width: auto; height: 70px; flex-direction: row; padding: 8px; }
  .sidebar-logo, .sidebar-foot { display: none; }
  .sidebar nav { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; width: 100%; }
  .nav-item { padding: 10px; }
  .app-main { margin: 0 0 70px; padding: 22px 16px; }
  .topbar { align-items: flex-start; }
  .top-actions span { display: none; }
  .logout-top { display: inline-flex; }
  .metric-grid { gap: 10px; }
  .metric { min-height: 130px; padding: 17px; }
  .metric strong { font-size: 34px; }
  .extension-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .users-panel { padding: 18px 14px; }
  .device-card { min-height: 360px; }
  .demo-call-card { padding: 20px; }
  .login-page { background: linear-gradient(180deg, #082f49 0 34%, #f5f8fa 34%); padding: 18px; }
  .login-shell { grid-template-columns: 1fr; gap: 10px; }
  .login-brand { padding: 20px; }
  .login-lockup { margin-bottom: 15px; }
  .login-lockup img { width: 45px; height: 45px; }
  .login-lockup strong { font-size: 26px; }
  .login-brand h1 { font-size: 34px; }
  .login-brand p { display: none; }
  .login-card { padding: 28px 22px; }
}
