/* Rakhmet Dashboard — Google/Material-like look with rakhmet.com palette */
:root {
  --brand-blue: #3c67a6;
  --brand-navy: #282b62;
  --brand-sky: #55a8db;
  --brand-light: #59b3e4;
  --brand-bright: #4179e5;
  --brand-ink: #000d1a;
  --brand-tint: #f0f5ff;
  --nav-active: #e1eaff;
  --border: #dde3ec;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #5f6b7d;
  --ok: #1e8e3e;
  --ok-bg: #e6f4ea;
  --err: #d93025;
  --err-bg: #fce8e6;
  --wait: #b06000;
  --wait-bg: #fef7e0;
  --shadow: 0 1px 2px rgba(60, 64, 67, .15), 0 1px 3px 1px rgba(60, 64, 67, .08);
  --radius: 12px;
  --topbar-h: 64px;
  --drawer-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 22px; font-weight: 400; margin: 0; color: var(--brand-ink); }
h2 { font-size: 15px; font-weight: 500; margin: 0 0 12px; color: var(--brand-navy); }
a { color: var(--brand-bright); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: "Roboto Mono", ui-monospace, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ell.narrow { max-width: 160px; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up { color: var(--ok); }
.down { color: var(--err); }

/* Top app bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand img { display: block; }
.spacer { flex: 1; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }
.menu-btn { display: none; }
.lang-switch { display: flex; gap: 4px; }
.lang-switch a {
  padding: 6px 10px; border-radius: 16px; color: var(--muted); font-weight: 500; font-size: 13px;
}
.lang-switch a.active { background: var(--brand-tint); color: var(--brand-blue); }
.lang-switch.center { justify-content: center; margin-top: 20px; }
.user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 500;
}
.user-name { font-weight: 500; font-size: 13px; }
.user-sub { font-size: 12px; color: var(--muted); }
.user form { margin: 0; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.drawer {
  width: var(--drawer-w); flex-shrink: 0; padding: 12px 12px 12px 0; background: var(--surface);
  border-right: 1px solid var(--border);
}
.drawer a {
  display: flex; align-items: center; gap: 16px;
  height: 44px; padding: 0 24px; margin-bottom: 2px;
  border-radius: 0 22px 22px 0; color: var(--text); font-weight: 500;
}
.drawer a svg { color: var(--muted); }
.drawer a:hover { background: var(--bg); }
.drawer a.active { background: var(--nav-active); color: var(--brand-navy); }
.drawer a.active svg { color: var(--brand-blue); }
.content { flex: 1; min-width: 0; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.period { margin: -4px 0 16px; }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px;
}
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 400; color: var(--brand-ink); margin: 8px 0 6px; white-space: nowrap; }
.kpi-value .cur { font-size: 14px; color: var(--muted); margin-left: 6px; }
.kpi-foot { display: flex; gap: 8px; font-size: 12.5px; align-items: baseline; }
.delta { font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1.4fr); gap: 16px; }
.chart-box { position: relative; height: 280px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); border: 0; padding: 0; margin: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.field-input {
  height: 40px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text);
  border: 1px solid #c4cbd6; border-radius: 8px; background: var(--surface); min-width: 0;
}
.field-input:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 1px var(--brand-blue); }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar select.field-input { max-width: 280px; }
.filters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; align-items: end; margin-bottom: 16px;
}
.filters .wide { grid-column: span 2; }
.filters .states { grid-column: span 2; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; min-height: 40px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--brand-blue); width: 16px; height: 16px; }
.filter-actions { display: flex; gap: 8px; }
.hint { grid-column: 1 / -1; margin: 0; font-size: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 20px; border-radius: 20px; border: 0; font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; letter-spacing: .1px;
}
.btn-primary { background: var(--brand-blue); color: #fff; }
.btn-primary:hover { background: #335a93; box-shadow: var(--shadow); }
.btn-outline { border: 1px solid #c4cbd6; color: var(--brand-blue); background: var(--surface); }
.btn-outline:hover { background: var(--brand-tint); }
.btn-text { background: transparent; color: var(--brand-blue); padding: 0 12px; }
.btn-text:hover { background: var(--brand-tint); }
.btn-block { width: 100%; }
.btn.disabled { pointer-events: none; opacity: .4; }

/* Chips & totals */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
  background: var(--bg); color: var(--muted);
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.err { background: var(--err-bg); color: var(--err); }
.chip.wait { background: var(--wait-bg); color: var(--wait); }
.totals { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.total-chip {
  display: flex; align-items: center; gap: 8px; background: var(--surface); box-shadow: var(--shadow);
  border-radius: 20px; padding: 6px 14px;
}

/* Tables */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted);
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fafbfd; white-space: nowrap;
}
.table th.num { text-align: right; }
.table td { white-space: nowrap; padding: 10px 16px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
.table tbody tr:hover { background: var(--brand-tint); }
.table.compact td, .table.compact th { padding: 8px 6px; background: transparent; }
.empty { padding: 32px; text-align: center; margin: 0; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 16px; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-info { background: var(--brand-tint); color: var(--brand-blue); }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 28px; padding: 40px 40px 28px; text-align: center;
}
.login-logo { height: 40px; margin-bottom: 20px; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card > p { margin: 0 0 24px; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: 16px; }
.login-card .btn-block { margin-top: 8px; }

/* Responsive */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .drawer {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 15;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  body.nav-open .drawer { transform: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .user-meta { display: none; }
  .filters .wide, .filters .states { grid-column: auto; }
}
@media (max-width: 520px) {
  .brand img { height: 26px; }
  .login-card { padding: 28px 20px 20px; border: 0; }
  .kpi-value { font-size: 22px; }
}
