/* ============ Design tokens ============ */
:root[data-theme="light"] {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-alt: #eef1f4;
  --border: #dfe3e9;
  --text: #1c2b39;
  --text-muted: #647085;
  --primary: #0f3d5c;
  --primary-hover: #0b2e46;
  --primary-soft: #e5edf2;
  --accent: #0e8a6d;
  --accent-soft: #e1f4ee;
  --danger: #c0392b;
  --danger-soft: #fbeae8;
  --warning: #b7791f;
  --warning-soft: #fbf1e0;
  --success: #1a8f5e;
  --success-soft: #e5f6ee;
  --info: #2b6cb0;
  --info-soft: #e8f1fb;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 6px 16px rgba(16, 24, 32, .07);
}

:root[data-theme="dark"] {
  --bg: #0e1620;
  --surface: #161f2b;
  --surface-alt: #1b2530;
  --border: #2a3644;
  --text: #e7edf3;
  --text-muted: #8ea0b3;
  --primary: #5aa8dd;
  --primary-hover: #79bae6;
  --primary-soft: #1c3242;
  --accent: #2fbf96;
  --accent-soft: #163a30;
  --danger: #e5695f;
  --danger-soft: #3a2020;
  --warning: #e0a930;
  --warning-soft: #3a2e14;
  --success: #3ecf8e;
  --success-soft: #16332a;
  --info: #5b9bd9;
  --info-soft: #182c3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .4);
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  -webkit-font-smoothing: antialiased;
  font-family: 'Public Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(120, 130, 145, .35); border-radius: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

a { color: inherit; text-decoration: none; }
input, select, button, textarea { font-family: 'Public Sans', sans-serif; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.heading-font { font-family: 'Manrope', sans-serif; }

/* ============ App shell ============ */
.app-shell { display: flex; width: 100%; min-height: 100vh; }

.sidebar {
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  width: 236px;
  transition: width .18s ease;
}
.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .hide-collapsed { display: none; }
/* Uygulanır durumu sayfa yüklenirken hemen (JS DOM hazır olmadan) yansıtmak için html üzerinde de aynı kural. */
html.sidebar-collapsed .sidebar { width: 72px; }
html.sidebar-collapsed .hide-collapsed { display: none; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid var(--border); min-height: 60px;
}
.sidebar-brand-icon {
  width: 32px; height: 32px; flex: none; border-radius: 8px;
  background: var(--primary); display: flex; align-items: center; justify-content: center;
}
.sidebar-brand-icon svg { width: 17px; height: 17px; color: #fff; }
.sidebar-brand-text { font-family: 'Manrope', sans-serif; font-weight: 800; font-size: 14.5px; line-height: 1.2; white-space: nowrap; }
.sidebar-brand-text span { font-weight: 500; font-size: 11.5px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; color: var(--text-muted); font-size: 13.5px; white-space: nowrap;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link.active { background: var(--accent-soft); color: var(--primary); font-weight: 700; }
.nav-link.active svg { color: var(--accent); }
.nav-sep { height: 1px; background: var(--border); margin: 8px 4px; }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); }
.sidebar-collapse-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; font-size: 12px;
}
.sidebar-collapse-btn svg { width: 15px; height: 15px; transition: transform .18s ease; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.mobile-backdrop { display: none; }
.hamburger-btn { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 60; width: 236px !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .hamburger-btn { display: inline-flex !important; }
  .mobile-backdrop.open {
    display: block; position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 55;
  }
}

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex: none; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-family: 'Manrope', sans-serif; font-weight: 800; font-size: 16.5px; }
.topbar-crumb { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); display: flex; align-items: center;
  justify-content: center; cursor: pointer;
}
.icon-btn svg { width: 17px; height: 17px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}

.main-content { flex: 1; padding: 20px; min-width: 0; }

/* ============ Cards ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.card-title { font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 14.5px; margin-bottom: 14px; }

/* ============ Dashboard ============ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1150px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.stat-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.stat-icon svg { width: 19px; height: 19px; }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-icon.accent { background: var(--accent-soft); color: var(--accent); }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-value { font-size: 22px; font-weight: 800; font-family: 'Manrope', sans-serif; }
.stat-label { font-size: 12.5px; color: var(--text-muted); }

.dash-2col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; }
@media (max-width: 920px) { .dash-2col { grid-template-columns: 1fr; } }

.week-chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; }
.week-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week-bar-col .v, .week-bar-col .day { font-size: 11px; color: var(--text-muted); }
.week-bar { width: 100%; max-width: 34px; border-radius: 6px 6px 2px 2px; background: var(--accent); }

/* ============ Tables ============ */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; box-shadow: var(--shadow); }
table.app-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.app-table th {
  padding: 10px 14px; font-size: 11px; text-transform: uppercase; color: var(--text-muted);
  letter-spacing: .4px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.app-table th.num, table.app-table td.num { text-align: right; }
table.app-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
table.app-table tbody tr:hover { background: var(--surface-alt); }
table.app-table th[data-sortable] { cursor: pointer; user-select: none; }
table.app-table th[data-sortable]:hover { color: var(--text); }
.td-muted { color: var(--text-muted); }
.td-strong { font-weight: 600; }
.td-mono { font-family: monospace; font-size: 12px; color: var(--text-muted); }
.td-ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state { padding: 52px 20px; text-align: center; color: var(--text-muted); }
.empty-state-icon {
  width: 44px; height: 44px; border-radius: 11px; background: var(--surface-alt);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;
}
.empty-state-icon svg { width: 22px; height: 22px; }
.empty-state-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* ============ Badges ============ */
.badge-status { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: inline-block; border: none; }
.badge-status.sm { padding: 3px 9px; border-radius: 6px; font-size: 11px; }
.badge-status.success { background: var(--success-soft); color: var(--success); }
.badge-status.warning { background: var(--warning-soft); color: var(--warning); }
.badge-status.danger { background: var(--danger-soft); color: var(--danger); }
.badge-status.info { background: var(--info-soft); color: var(--info); }
.badge-status.neutral { background: var(--surface-alt); color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; font-size: 13.5px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline-muted { background: var(--surface); color: var(--text-muted); border-color: var(--border); }
.btn-danger-outline { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn-sm { width: 28px; height: 28px; padding: 0; border-radius: 7px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn:disabled { opacity: .65; cursor: not-allowed; }
.btn .spinner { animation: spin .8s linear infinite; }

/* ============ Forms ============ */
.form-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-control, select.form-control {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13.5px;
}
.form-control::placeholder { color: var(--text-muted); }
.filter-bar { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filter-bar .field-label { display: block; font-size: 11.5px; color: var(--text-muted); margin-bottom: 5px; }
.filter-bar select, .filter-bar input { padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; }
.search-field { position: relative; flex: 1; max-width: 360px; }
.search-field svg { width: 15px; height: 15px; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-field input { width: 100%; padding: 9px 12px 9px 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; }
.pw-toggle-wrap { position: relative; }
.pw-toggle-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; display: flex; }
.pw-toggle-btn svg { width: 18px; height: 18px; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 14, 20, .5); z-index: 80;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-box { width: 100%; max-width: 440px; background: var(--surface); border-radius: 14px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-family: 'Manrope', sans-serif; font-weight: 800; font-size: 16px; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-top: 2px; }
.check-row input { width: 16px; height: 16px; }

/* ============ Toasts ============ */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); animation: toastIn .2s ease;
}
.toast-icon { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex: none; }
.toast-icon svg { width: 14px; height: 14px; }
.toast-msg { flex: 1; font-size: 13px; line-height: 1.4; padding-top: 2px; }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px; }
.toast-close svg { width: 13px; height: 13px; }

/* ============ Login ============ */
.login-split { display: flex; min-height: 100vh; width: 100%; }
@media (max-width: 820px) { .login-split { flex-direction: column; } .login-brand { min-height: 180px !important; padding: 28px 24px !important; } }
.login-brand {
  flex: 1 1 42%; min-height: 100vh; background: linear-gradient(160deg, var(--primary), var(--primary-hover));
  display: flex; flex-direction: column; justify-content: space-between; padding: 48px; color: #eef4f8;
}
.login-form-side { flex: 1 1 58%; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--surface); padding: 32px; }

/* ============ Empty page states ============ */
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; background: var(--surface-alt); font-size: 12.5px; }

.pagination-bar { display: flex; gap: 4px; margin-top: 14px; flex-wrap: wrap; }
.pagination-bar a, .pagination-bar span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px;
  padding: 0 8px; border-radius: 7px; border: 1px solid var(--border); font-size: 13px; color: var(--text);
}
.pagination-bar a:hover { background: var(--surface-alt); }
.pagination-bar .active { background: var(--primary); color: #fff; border-color: var(--primary); }
