:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --bg: #f1f5f9;
  --card: #ffffff;
  --field: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --field: #0b1220;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --ok: #22c55e;
  --ok-bg: #14321f;
  --warn: #f59e0b;
  --warn-bg: #3a2c10;
  --bad: #f87171;
  --bad-bg: #3a1717;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 auto;
}
.icon-btn:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.icon-btn svg { width: 18px; height: 18px; display: block; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--brand); }
.hidden { display: none !important; }

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 12%, var(--bg)), var(--bg));
}
.login-card {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .12);
  padding: 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-card img.logo { max-height: 72px; max-width: 200px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

label { display: block; text-align: left; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 15px;
  font-family: inherit;
  background: var(--field);
  color: var(--text);
}
textarea { resize: vertical; min-height: 64px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border: none; border-radius: 11px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600;
}
.btn:hover { background: var(--brand-dark); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--border); }
.btn.ghost:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.btn.ok { background: var(--ok); }
.btn.ok:hover { filter: brightness(.95); }
.btn.bad { background: var(--bad); }
.btn.bad:hover { filter: brightness(.95); }

/* ---- App shell (sol kenar menu) ---- */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.side-brand img.logo { max-height: 36px; max-width: 120px; }
.side-brand .brand { font-weight: 700; font-size: 16px; line-height: 1.2; }

.side-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tab {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 11px 14px; border-radius: 12px;
  background: transparent; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; color: var(--muted);
}
.tab:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--text); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent); }
.tab .tab-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.tab .tab-icon svg { width: 18px; height: 18px; display: block; }

.side-foot { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 8px; }
.side-foot .who { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.side-foot .who strong { color: var(--text); font-size: 14px; }
.side-foot-actions { display: flex; gap: 8px; }
.side-foot-actions .btn { flex: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  background: var(--card); position: sticky; top: 0; z-index: 9;
}
.main-head h1 { font-size: 19px; margin: 0; }

.container { max-width: 1000px; margin: 0 auto; padding: 22px; width: 100%; }

/* Sayfa gecis animasyonlari */
@keyframes pgUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pgLeft { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes pgRight { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes pgZoom { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes pgFade { from { opacity: 0; } to { opacity: 1; } }
.anim-up { animation: pgUp .3s ease; }
.anim-left { animation: pgLeft .3s ease; }
.anim-right { animation: pgRight .3s ease; }
.anim-zoom { animation: pgZoom .3s ease; }
.anim-fade { animation: pgFade .35s ease; }

/* ---- Takvim ---- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.cal-head { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; letter-spacing: .04em; }
.cal-blank { min-height: 70px; }
.cal-day {
  position: relative; min-height: 70px;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 8px; cursor: pointer; background: var(--field);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.cal-day:hover { transform: translateY(-2px); border-color: var(--brand); }
.cal-day .cal-num { font-size: 13px; font-weight: 600; color: var(--muted); }
.cal-day.today .cal-num { color: var(--brand); font-weight: 800; }
.cal-day.has { background: var(--card); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); }
.cal-day.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.cal-day .cal-count {
  position: absolute; top: 6px; right: 6px;
  font-size: 11px; font-weight: 700; color: #fff; background: var(--brand);
  min-width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 999px; padding: 0 5px;
}
.cal-day .cal-dots { position: absolute; bottom: 8px; left: 8px; display: flex; gap: 4px; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cal-dot.ok { background: var(--ok, #16a34a); }
.cal-dot.warn { background: var(--warn, #d97706); }
.cal-dot.bad { background: var(--bad, #dc2626); }
@media (max-width: 560px) {
  .cal { gap: 4px; }
  .cal-day, .cal-blank { min-height: 54px; }
  .cal-head { font-size: 10px; }
}

/* Mobil: sidebar drawer */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.3);
  }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .app-shell.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40;
  }
  .main-head #menu-btn { display: inline-flex !important; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 17px; }

/* Acilir-kapanir form kartlari */
.card.collapsible { padding: 0; overflow: hidden; }
.card.collapsible > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.card.collapsible > summary::-webkit-details-marker { display: none; }
.card.collapsible > summary::after {
  content: "";
  width: 10px; height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .2s ease;
  flex-shrink: 0;
  margin-left: 12px;
}
.card.collapsible[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.card.collapsible > summary:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.card.collapsible .collapse-body { padding: 0 20px 20px; border-top: 1px solid var(--border); }

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

/* stat cards */
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.stat .num { font-size: 26px; font-weight: 800; color: var(--brand); }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.approved { background: var(--ok-bg); color: var(--ok); }
.badge.rejected { background: var(--bad-bg); color: var(--bad); }
.badge.off { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }

.msg { padding: 11px 14px; border-radius: 11px; font-size: 14px; margin-bottom: 14px; }
.msg.error { background: var(--bad-bg); color: var(--bad); border: 1px solid #fecaca; }
.msg.success { background: var(--ok-bg); color: var(--ok); border: 1px solid #bbf7d0; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: 28px; font-size: 14px; }
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline > div { flex: 1; min-width: 120px; }

@media print {
  .sidebar, .main-head, .no-print, .btn { display: none !important; }
  .main, .app-shell { display: block; }
  .card { border: none; box-shadow: none; }
}
