html {
  font-size: 80%; /* შრიფტის ზომა 20%-ით შემცირებული — ყველა rem-ზე დაფუძნებული ზომა ავტომატურად მასშტაბირდება */
  overflow-x: hidden;
  max-width: 100%;
}

:root {
  --ink: #1b1f2a;
  --text: #1b1f2a;
  --paper: #f6f5f1;
  --card: #ffffff;
  --line: #e4e1d8;
  --accent: #2f5d50;
  --accent-light: #e6efe9;
  --gold: #b8860b;
  --danger: #b3432b;
  --muted: #6b6f7a;
  --radius: 10px;
  --hover-row: #faf9f6;
  --input-bg: #ffffff;
}

:root[data-theme="dark"] {
  --text: #e8e6df;
  --paper: #14171c;
  --card: #1c2028;
  --line: #2c313c;
  --accent: #4fa88f;
  --accent-light: #1e332c;
  --gold: #d4a017;
  --danger: #e0685a;
  --muted: #9aa0ab;
  --hover-row: #232830;
  --input-bg: #20242c;
}

* { box-sizing: border-box; }

body {
  background: var(--paper);
  color: var(--text);
  font-family: 'Noto Sans Georgian', 'Segoe UI', system-ui, sans-serif;
  margin: 0;
  transition: background .15s ease, color .15s ease;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.navbar {
  background: var(--ink);
  color: #fff;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.navbar .brand { font-size: 1.15rem; font-weight: 700; color: #fff; letter-spacing: .3px; }
.navbar .brand span { color: var(--gold); }
.navbar nav { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.navbar nav a {
  color: #d9d7cf; font-weight: 500; font-size: .92rem;
  padding: 5px 11px; border-radius: 6px; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08); transition: background .12s ease, color .12s ease;
}
.navbar nav a.active { color: #fff; background: var(--accent); border-color: var(--accent); text-decoration: none; }
.navbar nav a:hover { color: #fff; background: rgba(255,255,255,.16); text-decoration: none; }
.navbar .user-box { color: #b7bac2; font-size: .85rem; margin-left: 8px; white-space: nowrap; }

.container {
  max-width: 100%;
  margin: 0;
  padding: 14px 20px 30px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 10px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.grid {
  display: grid;
  gap: 10px;
}
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }

@media (max-width: 560px) {
  .container { padding: 10px 12px 24px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .grid-2 { grid-template-columns: 1fr; }
  .navbar { padding: 8px 12px; }
  .navbar .brand { font-size: 1rem; }
  .navbar nav a { padding: 5px 10px; font-size: .85rem; }
  .navbar .user-box { display: none; } /* ვიწრო ეკრანზე ადგილს ვზოგავთ */
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field { min-width: 0; width: 100%; }

  /* ცხრილი მწკრივ-ბარათებად — სვეტები ცალ-ცალკე ხაზზე, ჰორიზონტალური სქროლვის გარეშე */
  .card { overflow-x: visible; }
  table.responsive-table { min-width: 0; width: 100%; }
  table.responsive-table thead { display: none; }
  table.responsive-table, table.responsive-table tbody, table.responsive-table tr, table.responsive-table td {
    display: block; width: 100%;
  }
  table.responsive-table tr {
    border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 8px 10px;
  }
  table.responsive-table td {
    border: none; padding: 5px 0 5px 44%; position: relative; white-space: normal; min-height: 20px;
  }
  table.responsive-table td:before {
    content: attr(data-label);
    position: absolute; left: 0; top: 5px; width: 40%;
    font-weight: 600; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .3px;
  }
  table.responsive-table td:empty { display: none; }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: transform .12s ease, box-shadow .12s ease;
}
a.stat-card { cursor: pointer; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.stat-card.overdue { border-left-color: var(--danger); }
.stat-card.due-soon { border-left-color: var(--gold); }
.stat-card .num { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.stat-card .label { color: var(--muted); font-size: .85rem; margin-top: 3px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 15px;
  border-radius: 6px;
  font-size: .92rem;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: #244a40; text-decoration: none; color: #fff; }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent-light); color: var(--accent); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8f3521; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }

table { width: 100%; min-width: 620px; border-collapse: collapse; }
th, td { text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--line); font-size: .93rem; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .75rem; letter-spacing: .4px; }
tr:hover td { background: var(--hover-row); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600;
}
.badge-pending   { background: #eef1f4; color: #445; }
.badge-progress  { background: #e3ecfb; color: #2451a3; }
.badge-completed { background: #e2f3e6; color: #227a3d; }
.badge-overdue   { background: #fbe4e0; color: #b3432b; }
.badge-low       { background: #eef1f4; color: #556; }
.badge-medium    { background: #fdf1d9; color: #9a6a05; }
.badge-high      { background: #fbe4e0; color: #b3432b; }

form .field { margin-bottom: 10px; }
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=date],
select, textarea {
  width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: .95rem; font-family: inherit; background: var(--input-bg); color: var(--text);
}
textarea { min-height: 100px; resize: vertical; }

.alert { padding: 8px 14px; border-radius: 8px; margin-bottom: 10px; font-size: .92rem; }
.alert-error { background: #fbe4e0; color: #8a3320; }
.alert-success { background: #e2f3e6; color: #1f6b36; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 160px; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink);
}
.login-card {
  background: var(--card); border-radius: 14px; padding: 40px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3); color: var(--text);
}
.login-card h1 { font-size: 1.3rem; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: .88rem; }

.chart-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.muted { color: var(--muted); font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 20px 0; }
