:root {
  --navy: #0b2a4a;
  --blue: #1565c0;
  --blue-dark: #0d47a1;
  --orange: #f26a21;
  --bg: #f3f5f8;
  --line: #e3e8ef;
  --text: #1c2430;
  --muted: #66758a;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --card: #fff;
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 13px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: stretch;
  height: 52px;
  padding: 0 10px 0 8px;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 40;
  overflow: visible;
}
.brand {
  display: flex;
  align-items: center;
  padding: 5px 12px 5px 2px;
  margin-right: 6px;
  flex: 0 0 auto;
}
.brand img {
  height: 42px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  display: block;
  background: #fff;
  border-radius: 4px;
  padding: 3px 8px;
}
.login-right .brand { padding: 0; margin: 0 0 16px; }
.login-right .brand img,
.brand-login img {
  height: auto;
  width: min(320px, 100%);
  max-width: 320px;
  padding: 0;
  background: transparent;
  border-radius: 0;
}
.login { min-height: 100vh; }
.nav {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow: visible !important;
  min-width: 0;
}
.nav-item { position: relative; display: flex; align-items: stretch; }
.nav-item > a, .nav-item > button {
  background: none;
  border: 0;
  color: #fff;
  padding: 0 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}
.nav-item > a:hover, .nav-item > button:hover,
.nav-item.active > a, .nav-item.active > button,
.nav-item.open > button {
  background: #0d47a1;
}
.caret { font-size: 8px; opacity: .9; margin-left: 1px; }
.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--blue);
  color: #fff;
  min-width: 230px;
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
  z-index: 80;
  padding: 4px 0;
}
.nav-item:hover > .dropdown,
.nav-item.open > .dropdown,
.nav-item:focus-within > .dropdown {
  display: block !important;
}
.nav-item:nth-last-child(1) .dropdown,
.nav-item:nth-last-child(2) .dropdown { left: auto; right: 0; }
.nav-item:nth-last-child(1) .has-sub .sub { left: auto; right: 100%; }
.dropdown a, .dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 14px;
  cursor: pointer;
  color: #fff;
  font-size: 13px;
}
.dropdown a:hover, .dropdown button:hover { background: #0d47a1; }
.mi { width: 16px; text-align: center; opacity: .95; flex: 0 0 16px; }
.has-sub { position: relative; }
.has-sub > button { justify-content: flex-start; }
.has-sub .sub {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background: var(--blue);
  min-width: 190px;
  box-shadow: 4px 4px 16px rgba(0,0,0,.25);
  padding: 4px 0;
  z-index: 81;
}
.has-sub:hover > .sub, .has-sub.open > .sub { display: block !important; }
.user-slot { display: flex; align-items: center; gap: 8px; padding-left: 8px; flex: 0 0 auto; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; color: var(--blue);
  display: grid; place-items: center;
  font-weight: 800; font-size: 12px;
}
.user-slot a { color: #fff; font-size: 13px; }
.user-slot button.logout {
  background: transparent;
  color: #fff;
  border: 0;
  padding: 0 4px;
  cursor: pointer;
  opacity: .85;
}
.user-menu { position: relative; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-menu .dropdown { right: 0; left: auto; min-width: 140px; }
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  align-items: start;
}
.settings-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px 16px;
}
.settings-card h3 {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: 15px;
  font-weight: 700;
}
.settings-card .row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.settings-card .row > span { color: #445; font-size: 12px; }
.settings-card input, .settings-card select, .settings-card textarea {
  width: 100%;
  border: 1px solid #d5dde7;
  border-radius: 4px;
  padding: 6px 8px;
}
.yn { display: flex; gap: 0; }
.yn button {
  border: 1px solid #cfd8e3;
  background: #fff;
  padding: 5px 14px;
  cursor: pointer;
}
.yn button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.foot-actions {
  position: sticky; bottom: 0;
  background: #f3f5f8;
  padding: 10px 16px;
  display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--line);
}
@media (max-width: 1200px) {
  .settings-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .settings-grid { grid-template-columns: 1fr; }
}

.toolbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}
.page-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.badge {
  background: var(--blue);
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}
.spacer { flex: 1; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
}
.btn:hover { background: #f7f9fc; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-orange { background: var(--orange); color: #fff; border-color: var(--orange); }
.search {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  min-width: 220px;
  background: #fff;
}

.page { padding: 12px 16px 28px; }
.grid-wrap {
  background: #fff;
  border: 1px solid var(--line);
  overflow: auto;
  max-height: calc(100vh - 130px);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.data th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  text-align: left;
  font-weight: 600;
  color: #445;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  white-space: nowrap;
}
table.data td {
  border-bottom: 1px solid #eef2f6;
  padding: 8px 10px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.data tr:hover td { background: #f4f8ff; cursor: pointer; }
.empty { padding: 28px; color: var(--muted); }

.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.kpi .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.kpi .v { font-size: 22px; font-weight: 800; margin-top: 4px; }
.kpi .s { color: var(--muted); margin-top: 4px; }

.cal { background: #fff; border: 1px solid var(--line); }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: #f8fafc; border-bottom: 1px solid var(--line); }
.cal-head div, .cal-cell {
  padding: 8px;
  min-height: 92px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell.today { background: #fff8e1; }
.chip {
  background: #e8f1ff;
  color: var(--blue-dark);
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 11px;
  margin-top: 4px;
  display: block;
}

.drawer-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 60;
  display: flex; justify-content: flex-end;
}
.drawer {
  width: min(760px, 100%);
  background: #fff;
  height: 100%;
  overflow: auto;
  box-shadow: -8px 0 24px rgba(0,0,0,.12);
}
.drawer h2 { margin: 0; font-size: 18px; }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 16px 18px; }
.form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.form input, .form select, .form textarea {
  border: 1px solid var(--line); border-radius: 4px; padding: 8px 9px; color: var(--text);
}
.form .full { grid-column: 1 / -1; }

.login {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f4f7fb;
}
.login-left { padding: 72px 64px; background: linear-gradient(#f7fbff, #eef4fb); }
.login-left h1 { color: var(--blue); font-size: 36px; line-height: 1.15; margin: 0 0 12px; }
.login-left p { color: #4b5a6e; max-width: 460px; }
.login-right {
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 48px;
  box-shadow: -12px 0 40px rgba(15,23,42,.06);
  min-width: 0;
}
.login-right h2 { margin: 8px 0 4px; font-size: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-weight: 600; }
.field input { padding: 10px 12px; border: 1px solid #d7dee8; border-radius: 6px; }

.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700; }
.pill-green { background: #dcfce7; color: #166534; }
.pill-blue { background: #dbeafe; color: #1e40af; }
.pill-amber { background: #fef3c7; color: #92400e; }
.pill-gray { background: #e5e7eb; color: #374151; }
.pill-red { background: #fee2e2; color: #991b1b; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kanban-col { background: #eef2f7; border-radius: 8px; padding: 8px; min-height: 280px; }
.kanban-col h3 { margin: 4px 8px 8px; font-size: 12px; text-transform: uppercase; }
.kitem { background: #fff; border-radius: 6px; padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }

.cmd {
  position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 80;
  display: flex; justify-content: center; padding-top: 12vh;
}
.cmd-box { width: min(640px, 92vw); background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.cmd-box input { width: 100%; border: 0; padding: 14px 16px; font-size: 16px; outline: none; border-bottom: 1px solid var(--line); }
.cmd-box a, .cmd-box button { display: block; width: 100%; text-align: left; background: #fff; border: 0; padding: 10px 16px; cursor: pointer; }
.cmd-box a:hover, .cmd-box button:hover { background: #eef5ff; }

.wizard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; max-width: 920px; }
.steps { display: flex; gap: 8px; margin-bottom: 16px; }
.step { flex: 1; padding: 8px; border-radius: 6px; background: #eef2f7; text-align: center; font-weight: 700; }
.step.on { background: var(--blue); color: #fff; }

.muted { color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .kpi-row, .kanban { grid-template-columns: 1fr 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-left { display: none; }
}
