:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #63717a;
  --line: #d9e1e5;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --topbar: #172026;
  --input-bg: #ffffff;
  --message-bg: #e6f4f1;
  --message-line: #a9d8d0;
}

body.dark-theme {
  color-scheme: dark;
  --bg: #101418;
  --panel: #182127;
  --text: #eef4f5;
  --muted: #a8b6bd;
  --line: #33434b;
  --accent: #14b8a6;
  --accent-dark: #5eead4;
  --topbar: #080d10;
  --input-bg: #111a1f;
  --message-bg: #12302f;
  --message-line: #1f625d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}

.topbar {
  align-items: center;
  background: var(--topbar);
  color: #fff;
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
}

.brand {
  align-items: center;
  color: #fff;
  display: inline-flex;
  font-size: 20px;
}

.brand img {
  display: block;
  height: 48px;
  width: auto;
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.topbar a {
  color: #fff;
}

.topbar form {
  margin: 0;
}

button,
.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  min-height: 40px;
  padding: 10px 14px;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px;
}

.header-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

h1,
h2 {
  margin: 0 0 10px;
}

p {
  color: var(--muted);
  margin: 0 0 14px;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid .wide {
  grid-column: 1 / -1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.narrow {
  max-width: 560px;
}

.form p {
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  min-height: 40px;
  padding: 9px 11px;
  width: 100%;
}

.language-select {
  background: #24323a;
  border-color: #40515a;
  color: #fff;
  min-height: 36px;
  padding: 7px 10px;
  width: auto;
}

.theme-toggle {
  background: #24323a;
  border-color: #40515a;
  color: #fff;
  min-height: 36px;
  padding: 7px 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 16px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
}

.list-row span {
  color: var(--muted);
  display: block;
  font-size: 14px;
  margin-top: 4px;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.totals,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
}

.quick-actions {
  justify-content: flex-start;
  margin: 0 0 18px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  background: var(--message-bg);
  border: 1px solid var(--message-line);
  border-radius: 8px;
  padding: 10px 12px;
}

@media (max-width: 780px) {
  .topbar,
  .header-row,
  .list-row {
    align-items: stretch;
    flex-direction: column;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .page {
    padding: 18px;
  }
}

/* PAD-DON qo'shimchalari */
.topbar nav { flex-wrap: wrap; row-gap: 6px; }
.topbar nav a.active { text-decoration: underline; text-underline-offset: 6px; }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi small { color: var(--muted); display: block; font-size: 13px; }
.kpi strong { display: block; font-size: 24px; margin-top: 4px; }
.kpi span { color: var(--muted); font-size: 13px; }
.periods { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.periods a { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: var(--panel); font-size: 14px; }
.periods a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.periods form { display: flex; gap: 6px; align-items: center; }
.periods input { width: auto; min-height: 34px; padding: 5px 8px; }
.badge { border-radius: 999px; display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; background: var(--message-bg); }
.badge.bad { background: #fde7e4; color: #a8261b; }
.badge.ok { background: #e3f4ea; color: #17733b; }
body.dark-theme .badge.bad { background: #3d1d19; color: #ff9a8e; }
body.dark-theme .badge.ok { background: #173324; color: #7fe0a4; }
.muted { color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.form-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.form-row label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.message.error { background: #fde7e4; border-color: #f2b1a8; }
body.dark-theme .message.error { background: #3d1d19; border-color: #7a3a32; }
td form { display: inline; margin: 0; }
td button, td .button { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.calc-result { font-weight: 700; color: var(--accent-dark); margin-top: 6px; }
@media (max-width: 900px) { .grid.four, .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid.four, .grid.three { grid-template-columns: 1fr; } }

.brand { white-space: nowrap; margin-right: 18px; }
