:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #687386;
  --line: #dce2ea;
  --accent: #2473e6;
  --accent-dark: #1557b7;
  --good: #0f9f6e;
  --warn: #d97706;
  --danger: #d94848;
  --shadow: 0 14px 35px rgba(21, 34, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans Georgian", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 50%, #eef8f3 100%);
}

.login-panel {
  position: relative;
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-language {
  position: absolute;
  top: 18px;
  right: 18px;
}

.login-language select,
.topbar-actions select {
  min-height: 36px;
  width: auto;
  min-width: 72px;
  padding: 6px 8px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #14213d;
  color: #fff;
  font-weight: 800;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 14px;
}

.login-panel h1 {
  margin: 22px 0 6px;
  font-size: 28px;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
}

.form-stack,
.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #39465a;
  font-size: 13px;
  font-weight: 600;
}

.field-title {
  display: block;
  margin-bottom: 8px;
  color: #39465a;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(36, 115, 230, 0.12);
}

button[type="submit"],
.secondary-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button[type="submit"]:hover,
.secondary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: #d9e4f2;
}

.error-text {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  background: #101827;
  color: #f8fafc;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand span {
  display: block;
  margin-top: 2px;
  color: #91a2bb;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #c8d2e1;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin: 0 0 4px;
  font-size: 26px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 16px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.stat-card.warning strong {
  color: var(--warn);
}

.panel {
  padding: 16px;
}

.view > .panel + .panel {
  margin-top: 16px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h3 {
  margin: 0;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-header select,
.search-input {
  max-width: 240px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  align-items: start;
}

.operation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}

.report-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(130px, 0.8fr) minmax(130px, 0.8fr) auto auto;
  gap: 12px;
  align-items: end;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid h3,
.form-grid .full,
.form-grid button {
  grid-column: 1 / -1;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-row input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.permission-grid label {
  min-height: 34px;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-size: 12px;
}

.permission-grid input[type="checkbox"] {
  width: 15px;
  min-height: 15px;
  padding: 0;
}

.module-grid label {
  min-height: 42px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: #536174;
  font-weight: 700;
  background: #f8fafc;
}

td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td input.table-input {
  min-height: 32px;
  padding: 5px 7px;
  font-size: 12px;
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-button {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.mini-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.mini-button.danger {
  color: #b91c1c;
}

.muted-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 6px;
  background: #101827;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }

  .nav-item {
    text-align: center;
    font-size: 12px;
  }

  .split-layout,
  .operation-grid,
  .report-toolbar,
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
