:root {
  --paper: #EFE8D8;
  --paper-2: #E4DBC6;
  --paper-3: #D8CEB5;
  --ink: #20281F;
  --ink-soft: #4B5245;
  --ink-muted: #6B7365;
  --brass: #AB8148;
  --brass-light: #D9C29A;
  --brass-dark: #846030;
  --teal: #2E5C57;
  --teal-light: #DCE8E4;
  --teal-dark: #1E3F3B;
  --brick: #9C4433;
  --brick-light: #F3DCD5;
  --line: #C9BC9E;
  --line-light: #E0D6C1;
  --white: #FBF9F3;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 3px rgba(32, 40, 31, 0.08);
  --shadow-md: 0 4px 12px rgba(32, 40, 31, 0.1);
  --shadow-lg: 0 10px 25px rgba(32, 40, 31, 0.15);
  --font-serif: 'Zilla Slab', Georgia, serif;
  --font-sans: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

a { color: inherit; text-decoration: none; }

button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  background: none;
  font-size: 14px;
  transition: var(--transition);
}

input, select, textarea {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 11px;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

table { border-collapse: collapse; width: 100%; }

/* App Layout */
#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 20;
}

.brand {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.brand .mark {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--brass-light);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .sub {
  font-size: 11.5px;
  color: #9FA894;
  margin-top: 4px;
  line-height: 1.3;
}

.brand .status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: #8FD8A0;
  margin-top: 8px;
  background: rgba(143, 216, 160, 0.12);
  padding: 2px 8px;
  border-radius: 12px;
}

.brand .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 8px #4ADE80;
}

nav { padding: 14px 10px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius);
  color: #D8D9CD;
  margin-bottom: 4px;
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-item .icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  opacity: 0.8;
}

.nav-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5B6353;
  flex-shrink: 0;
  transition: var(--transition);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.nav-item.active {
  background: rgba(171, 129, 72, 0.22);
  color: var(--brass-light);
  font-weight: 600;
}

.nav-item.active .dot {
  background: var(--brass);
  box-shadow: 0 0 6px var(--brass);
}

.sidebar-foot {
  padding: 16px 18px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11.5px;
  color: #8B9382;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-foot button {
  color: #C9CBBB;
  font-size: 12px;
  text-align: left;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-foot button:hover {
  color: var(--brass-light);
}

/* Main Content Area */
main {
  flex: 1;
  min-width: 0;
  padding: 32px 44px 60px;
  max-width: 1200px;
}

/* Page Header */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.page-head h1 { font-size: 28px; letter-spacing: -0.2px; }
.page-head .desc {
  color: var(--ink-soft);
  font-size: 13.5px;
  margin-top: 4px;
  max-width: 600px;
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }
.card h3 { font-size: 17px; margin-bottom: 14px; color: var(--ink); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: #333e2c;
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.ghost:hover {
  border-color: var(--ink);
  background: rgba(32, 40, 31, 0.04);
}

.btn.brass {
  background: var(--brass);
  border-color: var(--brass-dark);
  color: var(--white);
}

.btn.brass:hover {
  background: var(--brass-dark);
}

.btn.danger {
  background: transparent;
  color: var(--brick);
  border: 1px solid var(--brick-light);
}

.btn.danger:hover {
  background: var(--brick-light);
  border-color: var(--brick);
}

.btn.wa {
  background: #E8F5E9;
  border: 1px solid #A5D6A7;
  color: #1B5E20;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn.wa:hover {
  background: #C8E6C9;
  border-color: #81C784;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Grid System */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* Forms */
label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 5px;
  font-weight: 500;
}

.field { margin-bottom: 14px; }
.field input, .field select, .field textarea { width: 100%; }

/* Stats Row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--brass);
}

.stat.teal::before { background: var(--teal); }
.stat.brick::before { background: var(--brick); }
.stat.ink::before { background: var(--ink); }

.stat .num {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--teal);
  line-height: 1.1;
}

.stat .lbl {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
  font-weight: 500;
}

/* Progress Track */
.progress-track {
  height: 9px;
  background: var(--paper-2);
  border-radius: 20px;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.progress-fill {
  height: 100%;
  background: var(--brass);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Data Table */
table.data th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--line);
  padding: 10px 12px;
  font-weight: 600;
  background: rgba(0,0,0,0.015);
}

table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-light);
  font-size: 13.5px;
  vertical-align: middle;
}

table.data tr:hover td { background: #F8F4EA; }

/* Badges and Tags */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
}

.tag.teal { background: var(--teal-light); color: var(--teal-dark); border: 1px solid rgba(46, 92, 87, 0.2); }
.tag.brass { background: #F4E8D3; color: var(--brass-dark); border: 1px solid rgba(171, 129, 72, 0.25); }
.tag.brick { background: var(--brick-light); color: var(--brick); border: 1px solid rgba(156, 68, 51, 0.2); }
.tag.gray { background: #E7E3D5; color: #5B574A; border: 1px solid var(--line); }

/* Empty States */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
}

/* Modals */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(32, 40, 31, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal-bg.open { display: flex; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 28, 22, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 620px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal h3 {
  font-size: 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line-light);
  padding-bottom: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  border-top: 1px solid var(--line-light);
  padding-top: 16px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 22px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Radio Group (Yoklama) */
.radio-group { display: flex; gap: 6px; }

.radio-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  margin: 0;
  transition: var(--transition);
}

.radio-group input { width: auto; padding: 0; margin: 0; }
.radio-group label.sel-var { border-color: var(--teal); background: var(--teal-light); color: var(--teal-dark); font-weight: 600; }
.radio-group label.sel-yok { border-color: var(--brick); background: var(--brick-light); color: var(--brick); font-weight: 600; }
.radio-group label.sel-gec { border-color: var(--brass); background: #F1E3C8; color: var(--brass-dark); font-weight: 600; }

/* Avatars */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--paper-2);
}

.avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--paper-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 15px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.student-cell { display: flex; align-items: center; gap: 12px; }

.photo-upload-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}

.photo-preview {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--brass);
  background: var(--paper-2);
  flex-shrink: 0;
}

.photo-preview-placeholder {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--paper-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 24px;
  flex-shrink: 0;
  border: 2px solid var(--line);
}

.timeline-cat { margin-bottom: 24px; }
.timeline-cat > .cat-title {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Search and Filter bar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.search-box {
  position: relative;
  min-width: 240px;
}

.search-box input {
  padding-left: 32px;
  width: 100%;
}

.search-box .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  font-size: 13px;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile & Responsive */
.mobile-nav-toggle {
  display: none;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 18px;
}

@media (max-width: 920px) {
  #app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    overflow-x: auto;
    padding: 6px 12px;
  }
  .brand { display: none; }
  nav { display: flex; padding: 4px; }
  .nav-item { white-space: nowrap; margin-bottom: 0; padding: 8px 12px; }
  .sidebar-foot { display: none; }
  main { padding: 20px 16px; }
  .stat-row, .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
}

/* Print Styles for Karne */
@media print {
  body { background: white; color: black; }
  .sidebar, .page-head button, .modal-actions, .toast, .btn { display: none !important; }
  main { max-width: 100%; padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
}
