:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --ink: #171a24;
  --muted: #737b8b;
  --line: #e7eaf1;
  --dark: #11141d;
  --dark-soft: #191d28;
  --yellow: #c018ff;
  --yellow-soft: #f8e8ff;
  --green: #1da86a;
  --green-soft: #e8f8f0;
  --red: #df5c62;
  --red-soft: #fff0f1;
  --blue: #13cbe6;
  --blue-soft: #e6fbff;
  --brand-gradient: linear-gradient(135deg, #d100ff 0%, #7438ff 48%, #08d8df 100%);
  --shadow: 0 16px 40px rgba(20, 25, 40, .08);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  background: var(--dark);
  color: #fff;
}

.login-visual {
  padding: 72px clamp(32px, 7vw, 110px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 20% 10%, rgba(209, 0, 255, .22), transparent 34%),
    radial-gradient(circle at 80% 80%, rgba(8, 216, 223, .2), transparent 40%),
    var(--dark);
}

.brand-lockup { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.04em; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #fff; background: var(--brand-gradient); font-weight: 900; font-size: 30px; line-height: 1; box-shadow: 0 8px 20px rgba(142, 24, 255, .3); }
.brand-name { font-size: 24px; }
.brand-sub { color: #aeb5c7; font-size: 13px; letter-spacing: .02em; margin-top: 4px; }
.login-hero { max-width: 560px; }
.login-hero h1 { font-size: clamp(42px, 5vw, 74px); line-height: .98; letter-spacing: -.07em; margin: 0 0 22px; }
.login-hero p { color: #b9c0d0; font-size: 18px; line-height: 1.6; max-width: 470px; }
.login-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.login-chip { border: 1px solid rgba(255,255,255,.12); border-radius: 100px; padding: 9px 13px; color: #c9cfdb; font-size: 13px; }
.login-note { color: #8e97a9; font-size: 12px; }

.login-panel { display: grid; place-items: center; padding: 32px; background: #fafbfe; color: var(--ink); }
.login-card { width: min(420px, 100%); padding: 38px; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.04em; }
.login-card > p { margin: 0 0 26px; color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 14px; }
.login-form label, .field label { display: grid; gap: 7px; font-size: 12px; font-weight: 700; color: #535b6b; }
.login-form input, .field input, .field select, .field textarea, .toolbar select, .toolbar input { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; background: #fff; color: var(--ink); outline: none; transition: border .2s, box-shadow .2s; }
.login-form input:focus, .field input:focus, .field select:focus, .field textarea:focus, .toolbar select:focus, .toolbar input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(85, 119, 232, .12); }
.login-demo { display: flex; justify-content: space-between; align-items: center; padding: 12px 13px; border-radius: 12px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.login-demo strong { color: var(--ink); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 15px; background: var(--dark); color: #fff; }
.sidebar .brand-lockup { padding: 0 12px; }
.sidebar .brand-mark { width: 36px; height: 36px; font-size: 19px; border-radius: 11px; }
.sidebar .brand-name { font-size: 20px; }
.demo-pill { margin: 28px 11px 18px; padding: 8px 11px; border-radius: 10px; color: #e4c95d; background: rgba(245, 197, 28, .1); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.nav { display: grid; gap: 4px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-radius: 11px; padding: 11px 12px; color: #929bad; background: transparent; text-align: left; font-size: 13px; transition: background .2s, color .2s; }
.nav button:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav button.active { color: #fff; background: var(--brand-gradient); font-weight: 800; }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255,255,255,.08); color: #8992a4; font-size: 11px; line-height: 1.5; }

.main-area { min-width: 0; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 36px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.82); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 10; }
.topbar-context { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-context strong { font-size: 15px; letter-spacing: -.02em; }
.context-divider { color: #c6cad4; }
.topbar select { border: 0; background: transparent; color: var(--muted); font-size: 13px; outline: none; }
.topbar-actions { display: flex; align-items: center; gap: 11px; }
.icon-button { width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 11px; display: grid; place-items: center; background: var(--surface); color: var(--muted); }
.avatar { width: 37px; height: 37px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--brand-gradient); font-size: 12px; font-weight: 900; }
.content { max-width: 1500px; margin: 0 auto; padding: 34px 36px 60px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.page-heading h1 { margin: 0; font-size: 30px; letter-spacing: -.06em; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

.button { border: 1px solid transparent; border-radius: 11px; padding: 10px 14px; font-size: 12px; font-weight: 800; transition: transform .2s, box-shadow .2s, background .2s; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--dark); color: #fff; box-shadow: 0 7px 18px rgba(17,20,29,.12); }
.button-primary:hover { background: #292e3b; }
.button-accent { background: var(--brand-gradient); color: #fff; box-shadow: 0 8px 18px rgba(125, 43, 235, .2); }
.button-secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.button-danger { border-color: #f3c6c9; background: var(--red-soft); color: #bd4d54; }
.button-small { padding: 7px 9px; font-size: 11px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 26px rgba(20,25,40,.04); }
.kpi-card .kpi-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi-card .kpi-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--yellow-soft); color: #9a7700; }
.kpi-card .kpi-value { margin-top: 16px; font-size: 30px; font-weight: 850; letter-spacing: -.06em; }
.kpi-card .kpi-foot { margin-top: 7px; color: var(--green); font-size: 11px; font-weight: 700; }
.kpi-card .kpi-foot.neutral { color: var(--muted); }

.dashboard-grid { display: grid; grid-template-columns: 1.35fr .85fr; gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 26px rgba(20,25,40,.04); overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; font-size: 14px; letter-spacing: -.02em; }
.panel-header span { color: var(--muted); font-size: 11px; }
.panel-body { padding: 20px; }
.bar-chart { display: flex; align-items: end; gap: 18px; height: 205px; padding: 12px 8px 4px; border-bottom: 1px solid var(--line); }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: end; gap: 8px; height: 100%; }
.bar-stack { width: min(42px, 100%); display: flex; align-items: end; height: 88%; gap: 3px; }
.bar { flex: 1; min-height: 8px; border-radius: 7px 7px 2px 2px; background: var(--yellow); }
.bar.secondary { background: #dde3f7; }
.bar-label { color: var(--muted); font-size: 10px; }
.chart-legend { display: flex; gap: 18px; margin-top: 14px; color: var(--muted); font-size: 11px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--yellow); }
.legend-dot.secondary { background: #dde3f7; }

.status-list { display: grid; gap: 12px; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border-radius: 12px; background: var(--surface-soft); }
.status-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-bullet { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-bullet.off { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.status-info strong { display: block; font-size: 12px; }
.status-info small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.status-text { color: var(--green); font-size: 11px; font-weight: 800; }
.status-text.off { color: var(--red); }

.activity-list { display: grid; gap: 15px; }
.activity-item { display: flex; gap: 11px; }
.activity-dot { flex: 0 0 28px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: #6c5d00; background: var(--yellow-soft); font-size: 13px; }
.activity-item p { margin: 0; font-size: 12px; line-height: 1.45; }
.activity-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar-left, .toolbar-right { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input { width: auto; min-width: 138px; padding: 10px 11px; font-size: 12px; }
.toolbar input { min-width: 210px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; white-space: nowrap; }
th { color: var(--muted); background: var(--surface-soft); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
td strong { display: block; font-size: 12px; }
td small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
tr:last-child td { border-bottom: 0; }
.tag { display: inline-flex; align-items: center; gap: 5px; border-radius: 100px; padding: 5px 8px; font-size: 10px; font-weight: 800; }
.tag.green { background: var(--green-soft); color: #188557; }
.tag.yellow { background: var(--yellow-soft); color: #8e7100; }
.tag.red { background: var(--red-soft); color: #c04d54; }
.tag.blue { background: var(--blue-soft); color: #5168c4; }

.company-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.company-card { padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.company-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.company-logo { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #202633, #59667c); font-size: 14px; font-weight: 900; }
.company-card h3 { margin: 13px 0 4px; font-size: 15px; letter-spacing: -.03em; }
.company-card p { margin: 0; color: var(--muted); font-size: 11px; }
.company-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0; }
.company-metric { padding: 10px; border-radius: 11px; background: var(--surface-soft); }
.company-metric b { display: block; font-size: 16px; letter-spacing: -.04em; }
.company-metric span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

.connection-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.connection-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.connection-card h3 { margin: 15px 0 4px; font-size: 15px; }
.connection-card p { margin: 0; color: var(--muted); font-size: 11px; }
.connection-actions { display: flex; gap: 8px; margin-top: 18px; }
.connection-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 14px; background: var(--yellow-soft); font-size: 22px; }
.connection-icon.off { background: var(--red-soft); }

.report-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.report-card { padding: 17px; border-radius: 15px; background: var(--dark); color: #fff; }
.report-card:nth-child(2) { background: #596de0; }
.report-card:nth-child(3) { background: #197c55; }
.report-card:nth-child(4) { background: #a47a00; }
.report-card span { color: rgba(255,255,255,.7); font-size: 11px; }
.report-card strong { display: block; margin-top: 14px; font-size: 27px; letter-spacing: -.06em; }
.report-card small { display: block; margin-top: 6px; color: rgba(255,255,255,.7); font-size: 10px; }

.user-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 18px; }
.role-card { padding: 18px; border-radius: 15px; background: var(--surface-soft); }
.role-card + .role-card { margin-top: 10px; }
.role-card h3 { margin: 0 0 5px; font-size: 13px; }
.role-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--ink); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 22px; background: rgba(9,12,20,.52); backdrop-filter: blur(5px); }
.modal { width: min(700px, 100%); max-height: 90vh; overflow: auto; border-radius: 22px; background: var(--surface); box-shadow: 0 28px 80px rgba(0,0,0,.24); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 23px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 18px; letter-spacing: -.04em; }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 22px; }
.modal-body { display: grid; gap: 16px; padding: 23px; }
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field-full { grid-column: 1 / -1; }
.field textarea { min-height: 135px; resize: vertical; line-height: 1.5; }
.file-drop { display: grid; place-items: center; min-height: 110px; border: 1px dashed #cbd0dc; border-radius: 13px; background: var(--surface-soft); color: var(--muted); text-align: center; font-size: 12px; }
.file-drop input { display: none; }
.file-preview { display: flex; align-items: center; gap: 10px; margin-top: 9px; padding: 9px; border-radius: 10px; background: var(--yellow-soft); color: #836700; font-size: 11px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 17px 23px; border-top: 1px solid var(--line); }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 60; max-width: 340px; padding: 13px 15px; border-radius: 13px; color: #fff; background: var(--dark); box-shadow: var(--shadow); font-size: 12px; animation: slide-in .25s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1080px) {
  .kpi-grid, .report-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .user-grid { grid-template-columns: 1fr; }
  .company-grid, .connection-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-visual { min-height: 42vh; padding: 34px 26px; }
  .login-hero h1 { font-size: 46px; }
  .login-panel { padding: 26px 18px; }
  .login-card { padding: 28px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -255px; z-index: 30; width: 248px; transition: left .25s; }
  .sidebar.open { left: 0; }
  .topbar { padding: 13px 18px; }
  .topbar-context { max-width: 62%; }
  .content { padding: 24px 18px 40px; }
  .page-heading { flex-direction: column; }
  .heading-actions { justify-content: flex-start; }
  .kpi-grid, .report-grid, .company-grid, .connection-grid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
}
