:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e5e9f0;
  --text: #172033;
  --muted: #6f7888;
  --blue: #145bdb;
  --blue-dark: #0d46ae;
  --sidebar: #111827;
  --sidebar-soft: #1b2434;
  --success: #16855b;
  --danger: #c33c45;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(21, 34, 50, .07);
  font-family: "Segoe UI Variable", "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input { font: inherit; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 44%) 1fr; background: var(--surface); }
.login-card { width: min(430px, calc(100% - 64px)); margin: auto; }
.brand { display: flex; align-items: center; gap: 11px; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: #fff; background: var(--blue); font-weight: 800; font-size: 14px; }
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; color: var(--muted); margin-top: 1px; font-size: 10px; letter-spacing: .14em; }
.brand-login { margin-bottom: 72px; }
.login-copy .eyebrow, .eyebrow { margin: 0 0 7px; color: var(--blue); text-transform: uppercase; font-weight: 700; font-size: 11px; letter-spacing: .12em; }
.login-copy h1 { margin: 0; font-size: 35px; letter-spacing: -.04em; }
.login-copy > p:last-child { color: var(--muted); line-height: 1.6; margin: 10px 0 28px; }
#login-form { display: grid; gap: 17px; }
#login-form label { display: grid; gap: 7px; color: #3d4657; font-size: 13px; font-weight: 600; }
#login-form input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px 13px; outline: none; transition: border-color .16s, box-shadow .16s; color: var(--text); }
#login-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 91, 219, .11); }
.button { min-height: 44px; border: 0; border-radius: 10px; font-weight: 700; cursor: pointer; }
.button-primary { margin-top: 3px; color: #fff; background: var(--blue); transition: background .15s, transform .15s; }
.button-primary:hover { background: var(--blue-dark); }
.button-primary:active { transform: translateY(1px); }
.button:disabled { opacity: .6; cursor: wait; }
.form-error { margin: -5px 0 0; color: var(--danger); font-size: 13px; }
.login-visual { position: relative; overflow: hidden; margin: 16px; border-radius: 20px; background: linear-gradient(145deg, #101b30, #182f59 60%, #145bdb); }
.visual-grid { position: absolute; inset: 0; opacity: .14; background-image: linear-gradient(rgba(255,255,255,.32) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.32) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(to bottom right, black, transparent 90%); }
.visual-copy { position: absolute; left: 54px; bottom: 54px; color: white; }
.visual-copy strong { display: block; font-size: 24px; margin: 12px 0 5px; }
.visual-copy p { margin: 0; color: rgba(255,255,255,.72); }
.status-dot { display: block; width: 11px; height: 11px; border-radius: 50%; background: #43d69a; box-shadow: 0 0 0 6px rgba(67,214,154,.14); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 15px; background: var(--sidebar); color: #fff; }
.sidebar-brand { padding: 2px 6px 26px; }
.sidebar-brand small { color: #8591a7; }
.main-nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 11px; border-radius: 9px; color: #b8c1d1; text-decoration: none; font-size: 13px; font-weight: 600; }
.nav-item > span { width: 20px; text-align: center; font-size: 17px; color: #8996aa; }
.nav-item.active { color: white; background: var(--sidebar-soft); }
.nav-item.active > span { color: #6ea3ff; }
.nav-item.disabled { opacity: .65; cursor: default; }
.nav-item em { margin-left: auto; color: #748197; font-size: 9px; font-style: normal; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-footer { margin-top: auto; padding: 16px 7px 3px; display: grid; gap: 8px; color: #6f7c91; }
.system-state { color: #a8b2c3; font-size: 11px; }
.system-state i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #36c98d; }

.workspace { min-width: 0; }
.topbar { min-height: 76px; display: flex; justify-content: space-between; align-items: center; padding: 13px 27px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.topbar .eyebrow { margin-bottom: 2px; font-size: 9px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 9px 5px 5px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.user-chip > span { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; color: #fff; background: #334155; font-size: 12px; font-weight: 700; }
.user-chip strong { display: block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.user-chip small { color: var(--muted); font-size: 9px; }
.icon-button { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: #5b6575; cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); }
.save-state { color: var(--success); font-size: 11px; min-width: 84px; text-align: right; }
.save-state.saving { color: var(--muted); }
.save-state.error { color: var(--danger); }

.content { padding: 27px; max-width: 1580px; margin: 0 auto; }
.welcome-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 19px; }
.welcome-row h2 { margin: 0; font-size: 23px; letter-spacing: -.03em; }
.welcome-row p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.dashboard-actions { color: var(--muted); font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 14px; align-items: stretch; }
.dashboard-widget { grid-column: span var(--span, 4); min-height: calc(var(--rows, 3) * 64px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.025); overflow: hidden; position: relative; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; will-change: transform; }
.dashboard-widget:hover { border-color: #d7dde7; box-shadow: var(--shadow); }
.dashboard-widget.dragging { opacity: .28; box-shadow: none; }
.widget-header { min-height: 49px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid #eef1f5; }
.widget-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 8px; background: #edf3ff; color: var(--blue); font-size: 12px; font-weight: 800; }
.widget-title { min-width: 0; }
.widget-title strong { display: block; font-size: 12px; }
.widget-title small { color: var(--muted); font-size: 9px; }
.drag-handle { margin-left: auto; padding: 7px 4px; color: #a5adba; cursor: grab; font-size: 15px; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.widget-content { height: calc(100% - 49px); display: flex; flex-direction: column; justify-content: space-between; padding: 17px; }
.metric { font-size: 30px; line-height: 1; font-weight: 700; letter-spacing: -.04em; }
.metric-sub { margin-top: 7px; color: var(--muted); font-size: 11px; }
.widget-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; padding-top: 12px; border-top: 1px solid #f0f2f5; color: #7c8595; font-size: 10px; }
.module-badge { padding: 4px 7px; border-radius: 999px; background: #f1f4f8; color: #657084; font-weight: 600; }
.drag-placeholder { grid-column: span var(--span, 4); min-height: calc(var(--rows, 3) * 64px); border: 2px dashed #7ba7ef; border-radius: var(--radius); background: rgba(20,91,219,.055); box-shadow: inset 0 0 0 1px rgba(20,91,219,.03); }
.dashboard-grid.drag-active .dashboard-widget:not(.dragging) { transition: transform .18s ease; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 76px 1fr; }
  .sidebar { padding-inline: 11px; }
  .sidebar-brand span:last-child, .nav-item:not(.active) em, .nav-item { font-size: 0; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item > span { font-size: 18px; }
  .sidebar-footer { display: none; }
  .dashboard-widget { --span: 6 !important; }
}
@media (max-width: 720px) {
  .login-view { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-card { width: min(430px, calc(100% - 40px)); }
  .brand-login { margin-bottom: 48px; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .save-state, .user-chip div { display: none; }
  .content { padding: 18px 14px; }
  .welcome-row { align-items: flex-start; gap: 10px; }
  .dashboard-actions { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-widget, .drag-placeholder { grid-column: span 1 !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
