/* AI Core · Karar Merkezi. Light and lively: white surfaces, saturated blue. */
:root {
  --blue: #1f5eff;
  --blue-700: #1648d6;
  --blue-600: #2a66ff;
  --blue-100: #dbe5ff;
  --blue-50: #eef3ff;
  --ink: #0d1626;
  --ink-2: #364055;
  --muted: #687389;
  --line: #e3e8f1;
  --bg: #f5f7fc;
  --card: #ffffff;
  --green: #0a9467;
  --green-50: #e4f6ee;
  --red: #d92d20;
  --red-50: #fdecea;
  --violet: #6a4fd6;
  --violet-50: #f0ecfd;
  --gray-50: #f0f2f6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(13, 22, 38, 0.04), 0 4px 16px rgba(13, 22, 38, 0.04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-700); }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Top bar and tabs */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner, .tabs-inner, .page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}
.topbar-inner { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--blue) 0%, #4f86ff 100%);
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 0.02em;
}
.tenant-name { color: var(--ink-2); font-weight: 600; padding-left: 12px; border-left: 1px solid var(--line); }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.user form { margin: 0; }
.tabs { border-top: 1px solid var(--line); }
.tabs-inner { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs-inner::-webkit-scrollbar { display: none; }
.tab {
  white-space: nowrap; padding: 11px 12px; color: var(--ink-2); font-weight: 550; font-size: 14px;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--blue); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.page { padding-top: 22px; padding-bottom: 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* Hero */
.hero {
  background: linear-gradient(120deg, var(--blue) 0%, #3f7bff 60%, #5b8fff 100%);
  color: #fff; border-radius: 18px; padding: 22px 22px 20px; margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(31, 94, 255, 0.22);
}
.hero h1 { font-size: 24px; }
.hero p { opacity: 0.92; margin-top: 4px; }
.hero-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.28); font-size: 13px; font-weight: 600;
}
.chip.stop { background: #fff; color: var(--red); border-color: #fff; }

/* Cards and grid */
.grid { display: grid; gap: 14px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); min-width: 0;
}
.card + .card, .section + .section { margin-top: 14px; }
.section { margin-top: 22px; }
/* Grid items are spaced by the grid gap, not by sibling margins. */
.grid > .card, .grid > .section, .legend > .card { margin-top: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.kpi-top { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.kpi-icon {
  width: 32px; height: 32px; border-radius: 10px; background: var(--blue-50); color: var(--blue);
  display: grid; place-items: center; flex: none;
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-value { font-size: 26px; font-weight: 750; margin-top: 12px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 15px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.kpi-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.bar { height: 6px; background: var(--gray-50); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }

/* Badges and dots */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: var(--gray-50); color: var(--ink-2); white-space: nowrap;
}
.badge.blue { background: var(--blue-50); color: var(--blue-700); }
.badge.green { background: var(--green-50); color: var(--green); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.violet { background: var(--violet-50); color: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b6bdca; display: inline-block; flex: none; }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px rgba(10, 148, 103, 0.15); }
.dot.violet { background: var(--violet); }
.dot.red { background: var(--red); }
.lvl { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; font-weight: 750; font-size: 13px; }
.lvl-0 { background: var(--gray-50); color: var(--muted); }
.lvl-1 { background: var(--violet-50); color: var(--violet); }
.lvl-2 { background: var(--blue-50); color: var(--blue-700); }
.lvl-3 { background: var(--blue-100); color: var(--blue-700); }
.lvl-4 { background: var(--blue); color: #fff; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 6px 0; }

/* Tables: become stacked cards on phones */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  font-weight: 650; padding: 0 10px 8px; border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .w-num { width: 70px; text-align: center; }
.limits { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

/* Forms and buttons */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #d3daE6; border-radius: 10px;
  padding: 9px 11px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 120px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.15); }
input[disabled], select[disabled] { background: var(--gray-50); color: var(--muted); }
.help { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--red); font-size: 13px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 650;
  font-size: 14px; border-radius: 10px; padding: 9px 16px; border: 1px solid transparent; cursor: pointer;
  background: var(--blue); color: #fff; text-decoration: none;
}
.btn:hover { background: var(--blue-700); color: #fff; }
.btn.secondary { background: #fff; color: var(--ink); border-color: #d3dae6; }
.btn.secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b42318; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 11px 14px; border-radius: 12px; background: var(--blue-50); color: var(--blue-700); font-weight: 550; }
.messages li.error { background: var(--red-50); color: var(--red); }
.messages li.success { background: var(--green-50); color: var(--green); }

/* Result block, legend */
.result { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--gray-50); border-radius: 12px; padding: 14px; font-size: 14px; }
.legend { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.legend .card { padding: 14px; }
.legend p { color: var(--muted); font-size: 13px; margin-top: 8px; }
.meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.meta div { background: var(--gray-50); border-radius: 12px; padding: 10px 12px; }
.meta dt { font-size: 12px; color: var(--muted); }
.meta dd { margin: 2px 0 0; font-weight: 650; overflow-wrap: anywhere; }
.token-box { background: var(--ink); color: #fff; border-radius: 12px; padding: 14px; overflow-wrap: anywhere; }
.pagination { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--blue-50), #fff 55%); }
.auth .card { width: 100%; max-width: 380px; padding: 26px; }
.auth .brand { margin-bottom: 18px; font-size: 18px; }
.auth .field { margin-bottom: 12px; }
.auth .btn { width: 100%; margin-top: 6px; }

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .topbar-inner, .tabs-inner, .page { padding: 0 14px; }
  .page { padding-top: 16px; }
  .tenant-name { display: none; }
  .user .who { display: none; }
  .hero { padding: 18px; border-radius: 16px; }
  .hero h1 { font-size: 21px; }
  .grid-3, .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-grid .card { padding: 14px; }
  .kpi-grid > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi-value { font-size: 22px; }
  .kpi-top { flex-direction: column; align-items: flex-start; gap: 8px; font-size: 13.5px; }
  .kpi-icon { width: 30px; height: 30px; border-radius: 9px; }
  .kpi-icon svg { width: 16px; height: 16px; }
  .kpi-value { margin-top: 8px; }
  .legend { grid-template-columns: minmax(0, 1fr); }
  .table thead { display: none; }
  .table, .table tbody { display: block; width: 100%; }
  .table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: inline-flex; align-items: center; gap: 7px; width: auto; max-width: 100%; border: 0; padding: 0; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
  .table td[data-label=""], .table td.empty { display: block; flex-basis: 100%; order: -1; }
  .table td[data-label=""]::before { content: none; }
  .table .w-num { width: auto; text-align: left; }
}
