:root {
  --page: #f2f6fa;
  --text: #142d4d;
  --muted: #5b6b7f;
  --line: #dbe4ee;
  --line-strong: #c7d5e2;
  --card: #ffffff;
  --navy: #073864;
  --navy-dark: #061d38;
  --side-text: #dbe9f5;
  --accent: #1565c0;
  --accent-soft: #e3effb;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --ok: #2e7d32;
  --ok-soft: #e8f5e9;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: 236px; overflow-y: auto;
  background: linear-gradient(180deg, var(--navy), var(--navy-dark)); color: #fff; padding: 18px 12px;
  z-index: 20; transition: transform .2s; display: flex; flex-direction: column;
}
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 4px 6px 16px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 10px; }
.brand img { width: 88px; height: 88px; object-fit: contain; border-radius: 10px; background: #fff; padding: 5px; }
.brand b { display: block; font-size: 15px; line-height: 1.25; margin-top: 4px; overflow-wrap: anywhere; }
.brand span { font-size: 12px; color: var(--side-text); opacity: .8; }
.side .nav { flex: 1; }
.side-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 10px; margin-top: 10px; }
.side-foot .who { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 4px 12px 8px; }
.side-foot .who .name { color: #fff; font-weight: 600; overflow-wrap: anywhere; }
.side-foot .role { background: rgba(255,255,255,.16); color: #fff; }
.nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: var(--side-text);
  text-align: left; padding: 10px 12px; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600; }
.nav-btn img { width: 20px; height: 20px; filter: brightness(0) invert(1); opacity: .85; }
.nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-fab { display: none; position: fixed; top: 10px; left: 10px; z-index: 15; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: var(--side-text);
  text-align: left; padding: 10px 12px; border-radius: 7px; margin: 2px 0; cursor: pointer; font: inherit; font-weight: 600;
}
.nav button img { width: 20px; height: 20px; filter: brightness(0) invert(1); opacity: .85; }
.nav button.active img, .nav button:hover img { opacity: 1; }
.nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav button.active { background: rgba(255,255,255,.16); color: #fff; }
.main { margin-left: 236px; min-height: 100vh; }
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 12px 24px;
  background: rgba(242,246,250,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.top .title { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.content { padding: 20px 24px 48px; max-width: 1400px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.role { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 11px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: #fff; color: #153354;
  border-radius: 6px; padding: 8px 12px; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn img { width: 18px; height: 18px; }
/* Icons are black PNGs: show them white on dark backgrounds. */
.btn.primary img { filter: brightness(0) invert(1); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0d47a1; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.sm img { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px; border-radius: 5px; }
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn img { width: 18px; height: 18px; display: block; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; margin: 4px 0 6px; }
.check input { width: 16px; height: 16px; margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar .grow { flex: 1; min-width: 200px; }

/* ---------- cards & tables ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; gap: 12px; align-items: center; }
.card.click { cursor: pointer; }
.card.click:hover { border-color: var(--accent); }
.card img { width: 40px; height: 40px; }
.card .num { font-size: 22px; font-weight: 700; color: var(--navy); }
.card .num small { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.cols2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #eef3f8; font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: #f7fafd; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.code { font-weight: 700; color: var(--navy); white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef3f8; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); display: block; }

/* donut */
.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; position: relative; flex: none; }
.donut::after { content: ""; position: absolute; inset: 30px; background: #fff; border-radius: 50%; }
.legend { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.bars .bar { display: grid; grid-template-columns: 140px 1fr 50px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; cursor: pointer; }
.bars .bar:hover .track span { filter: brightness(1.1); }
.bars .track { height: 12px; background: #eef3f8; border-radius: 6px; overflow: hidden; }
.bars .track span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }

.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.report-item { display: flex; gap: 10px; align-items: center; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; font: inherit; color: inherit; }
.report-item:hover { border-color: var(--accent); }
.report-item img { width: 32px; height: 32px; }
.report-item b { display: block; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(6,29,56,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.narrow { max-width: 460px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; }
.modal .body { padding: 18px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: #f8fafc; border-radius: 0 0 10px 10px; }
.toast-box { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 380px; }
.toast.error { background: var(--danger); }
.notice { padding: 10px 12px; border-radius: 7px; background: var(--accent-soft); color: #0d3c6e; margin-bottom: 12px; font-size: 13px; }
.notice.warn { background: var(--warn-soft); color: #6b4100; }
.notice.bad { background: #fdecea; color: #8a1c1c; }
.banner-box { padding: 0 24px; max-width: 1400px; }
.banner-box:empty { display: none; }
.banner-box .notice { margin: 16px 0 0; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.plan { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.plan h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.plan .price { font-size: 26px; font-weight: 700; }
.plan .price small { font-size: 13px; font-weight: 400; color: var(--muted); }
.list-editor textarea { min-height: 180px; font-family: inherit; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 9px 14px; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.file-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.file-row input[type=file] { width: auto; flex: 1; min-width: 180px; padding: 5px; }

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: linear-gradient(160deg, var(--navy), var(--navy-dark)); }
.auth-card { background: #fff; border-radius: 12px; width: 100%; max-width: 420px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-card .logo img { width: 52px; height: 52px; object-fit: contain; border-radius: 10px; }
.auth-card .logo b { font-size: 18px; display: block; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.error-box { background: var(--danger-soft); color: var(--danger); padding: 9px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .side { transform: translateX(-100%); }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .main { margin-left: 0; }
  .menu-fab { display: inline-flex; }
  .main { padding-top: 52px; }
  .content { padding: 16px; }
  .banner-box { padding: 0 16px; }
  .top { padding: 10px 16px; }
  .cols2, .grid2, .grid3 { grid-template-columns: 1fr; }
  .user-chip .name { display: none; }
  .top .btn .label { display: none; }
  .bars .bar { grid-template-columns: 100px 1fr 40px; }
}
@media print {
  .side, .top, .menu-fab { display: none; }
  .main { margin: 0; }
}

/* Password show / hide */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 40px; }
.pass-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: flex; }
.pass-toggle:hover, .pass-toggle:focus-visible { color: var(--accent); background: var(--accent-soft); }

/* Login page language picker */
.lang-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.lang-row select { width: auto; padding: 4px 8px; font-size: 13px; }
/* Hide the English text until the translation has loaded */
.i18n-pending { visibility: hidden; }

/* Sign-in page extras */
.center { text-align: center; }
.auth-card h3 { margin: 0 0 6px; font-size: 16px; }
.auth-card a { color: var(--accent); }
.auth-card .notice { margin-bottom: 12px; }
