*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#f4f6fb;
  --white:#fff;
  --panel:#fff;
  --border:#e5e8f0;
  --border2:#d0d4e4;
  --ink:#1a1d2e;
  --ink2:#374151;
  --sub:#6b7280;
  --sub2:#9ca3af;
  --blue:#4361ee;
  --blue2:#3451d1;
  --blue-lt:#eef1fd;
  --green:#10b981;
  --orange:#f59e0b;
  --red:#ef4444;
  --purple:#8b5cf6;
  --font:'Inter',sans-serif;
  --r:10px;
}
html,body{height:100%;font-family:var(--font);font-size:13px;background:var(--bg);color:var(--ink)}

/* ── TOP BAR ── */
.topbar{height:52px;background:var(--white);border-bottom:1px solid var(--border);display:flex;align-items:center;padding:0 20px;gap:12px;position:sticky;top:0;z-index:200;box-shadow:0 1px 4px rgba(0,0,0,.05)}
.topbar-logo{font-size:16px;font-weight:800;color:var(--ink);display:flex;align-items:center;gap:8px;letter-spacing:-.03em}
.logo-icon{width:28px;height:28px;background:linear-gradient(135deg,#4361ee,#8b5cf6);border-radius:7px;display:flex;align-items:center;justify-content:center;color:#fff;font-size:13px}
.topbar-sub{font-size:12px;color:var(--sub);font-weight:400}
.topbar-right{margin-left:auto;display:flex;gap:6px}

/* ── LAYOUT ── */
.layout{display:grid;grid-template-columns:340px 1fr;height:calc(100vh - 52px);overflow:hidden}
.left-col{background:var(--panel);border-right:1px solid var(--border);overflow-y:auto;display:flex;flex-direction:column}
.right-col{overflow-y:auto;padding:0}

/* ── PANEL BLOCK ── */
.pblock{border-bottom:1px solid var(--border);padding:16px}
.pblock-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--sub);margin-bottom:12px;display:flex;align-items:center;gap:6px}
.pblock-title span{font-size:16px}

/* ── TABS ── */
.tab-bar{display:flex;background:var(--bg);border-radius:8px;padding:3px;margin-bottom:14px;gap:2px}
.tb{flex:1;padding:6px 4px;text-align:center;font-size:12px;font-weight:600;border:none;background:transparent;cursor:pointer;border-radius:6px;color:var(--sub);font-family:var(--font);transition:.15s}
.tb.on{background:var(--white);color:var(--blue);box-shadow:0 1px 3px rgba(0,0,0,.1)}
.tab-pane{display:none}.tab-pane.on{display:block}

/* ── FORM FIELDS ── */
.field{margin-bottom:10px}
.fl{display:block;font-size:11px;font-weight:600;color:var(--ink2);margin-bottom:4px}
input[type=text],input[type=time],input[type=number],select,textarea{
  width:100%;background:#f9fafc;border:1px solid var(--border);color:var(--ink);
  padding:8px 10px;border-radius:7px;font-family:var(--font);font-size:12.5px;
  outline:none;transition:.15s;
}
input:focus,select:focus,textarea:focus{border-color:var(--blue);background:#fff;box-shadow:0 0 0 3px rgba(67,97,238,.1)}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:8px}

/* Days toggle */
.days-row{display:flex;gap:4px;flex-wrap:wrap}
.dc{position:relative}
.dc input{position:absolute;opacity:0;width:0;height:0}
.dc label{width:33px;height:30px;display:flex;align-items:center;justify-content:center;border:1px solid var(--border);border-radius:6px;background:#f9fafc;cursor:pointer;font-size:11px;font-weight:700;color:var(--sub);transition:.15s;user-select:none}
.dc input:checked+label{background:var(--blue);border-color:var(--blue);color:#fff}
.dc label:hover{border-color:var(--blue-lt)}

/* Color swatches */
.swatches{display:flex;gap:5px;flex-wrap:wrap;margin-top:4px}
.sw{width:22px;height:22px;border-radius:5px;cursor:pointer;border:2px solid transparent;transition:.1s}
.sw.on{border-color:#000;transform:scale(1.15)}

/* Buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;padding:8px 14px;border-radius:7px;font-size:12px;font-weight:600;cursor:pointer;border:none;font-family:var(--font);transition:.15s;white-space:nowrap}
.btn-blue{background:var(--blue);color:#fff}.btn-blue:hover{background:var(--blue2)}
.btn-outline{background:#fff;border:1px solid var(--border2);color:var(--ink2)}.btn-outline:hover{border-color:var(--blue);color:var(--blue)}
.btn-ghost{background:transparent;color:var(--sub);border:1px solid var(--border)}.btn-ghost:hover{color:var(--ink);border-color:var(--border2)}
.btn-full{width:100%}
.btn-red{background:#fef2f2;color:var(--red);border:1px solid #fecaca}.btn-red:hover{background:#fee2e2}
.btn-green{background:#ecfdf5;color:var(--green);border:1px solid #a7f3d0}.btn-green:hover{background:#d1fae5}
.btn-sm{padding:6px 10px;font-size:11px}

/* Stats row */
.stats-row{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:0}
.stat-box{background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:10px 12px;text-align:center}
.stat-num{font-size:22px;font-weight:800;color:var(--ink);line-height:1}
.stat-lbl{font-size:10px;color:var(--sub);margin-top:3px;font-weight:500}

/* Cases */
.case-list{display:flex;flex-direction:column;gap:6px}
.case-card{border:1px solid var(--border);border-radius:8px;padding:10px 12px;cursor:pointer;transition:.15s;background:#fff}
.case-card:hover,.case-card.on{border-color:var(--blue);background:var(--blue-lt)}
.cc-title{font-size:12px;font-weight:700;color:var(--ink)}
.cc-meta{font-size:11px;color:var(--sub);margin-top:2px}
.case-new{border:1px dashed var(--border2);border-radius:8px;padding:10px 12px;cursor:pointer;transition:.15s;text-align:center;color:var(--sub);font-size:12px;font-weight:600}
.case-new:hover{border-color:var(--blue);color:var(--blue)}

/* Design grid */
.design-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:6px}
.dg-item{border:2px solid var(--border);border-radius:7px;padding:6px 4px;cursor:pointer;text-align:center;transition:.15s;background:#f9fafc}
.dg-item:hover{border-color:var(--border2)}
.dg-item.on{border-color:var(--blue);background:var(--blue-lt)}
.dg-thumb{height:22px;border-radius:4px;margin-bottom:4px}
.dg-name{font-size:10px;font-weight:600;color:var(--ink2)}

/* ── RIGHT SIDE ── */
.tt-area{padding:16px 20px}

/* Toolbar */
.tt-toolbar{display:flex;align-items:center;gap:6px;margin-bottom:14px;flex-wrap:wrap}
.tt-toolbar-title{font-size:16px;font-weight:800;color:var(--ink);letter-spacing:-.02em;flex:1}
.tt-name-input{font-size:16px;font-weight:800;color:var(--ink);border:none;background:transparent;outline:none;font-family:var(--font);letter-spacing:-.02em;min-width:200px}
.tt-name-input:focus{border-bottom:2px solid var(--blue)}

/* Conflict alert */
.conflict-bar{background:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:10px 14px;margin-bottom:12px;display:none}
.conflict-bar.on{display:block}
.conflict-bar-title{font-size:12px;font-weight:700;color:var(--red);margin-bottom:4px}
.conflict-item{font-size:11px;color:#7f1d1d;line-height:1.6}

/* THE TIMETABLE */
.tt-container{background:#fff;border:1px solid var(--border);border-radius:var(--r);overflow:hidden;box-shadow:0 1px 6px rgba(0,0,0,.05)}
.tt-table-wrap{overflow-x:auto}

table.tt{width:100%;border-collapse:collapse;min-width:580px}
table.tt thead th{
  padding:10px 8px;font-size:11px;font-weight:700;letter-spacing:.04em;
  text-transform:uppercase;color:var(--sub);background:#f8f9fc;
  border-bottom:2px solid var(--border);text-align:center;white-space:nowrap
}
table.tt thead th.tc{text-align:right;min-width:72px;padding-right:10px}
table.tt tbody td{
  border:1px solid var(--border);vertical-align:top;
  padding:2px;height:54px;position:relative;min-width:110px
}
table.tt tbody td.tc{
  background:#f8f9fc;border-right:2px solid var(--border2);
  text-align:right;padding:0 10px 0 4px;font-size:11px;
  color:var(--sub);font-weight:600;vertical-align:middle;min-width:72px;
  white-space:nowrap;font-family:monospace
}
table.tt tbody td:hover{background:#fafbff}
table.tt tbody tr:last-child td{border-bottom:none}

/* Course block */
.cb{
  height:100%;border-radius:6px;padding:4px 6px;
  cursor:pointer;display:flex;flex-direction:column;
  justify-content:center;overflow:hidden;position:relative;transition:.12s
}
.cb:hover{filter:brightness(1.05);transform:translateY(-1px);box-shadow:0 2px 8px rgba(0,0,0,.1)}
.cb-code{font-size:10px;font-weight:800;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cb-name{font-size:11px;font-weight:600;line-height:1.2;margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cb-sub{font-size:9.5px;opacity:.8;margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cb-del{position:absolute;top:2px;right:2px;width:14px;height:14px;background:rgba(0,0,0,.25);border:none;color:#fff;border-radius:3px;font-size:9px;cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:.1s}
.cb:hover .cb-del{opacity:1}
.cb-del:hover{background:rgba(0,0,0,.5)}

.conflict-td{background:#fff5f5!important}
.conflict-dot{position:absolute;top:2px;left:2px;width:7px;height:7px;background:var(--red);border-radius:50%}

.empty-slot{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:var(--sub2);font-size:18px;opacity:0;transition:.15s;cursor:default;border-radius:6px}
table.tt tbody td:not(.tc):hover .empty-slot{opacity:.35}

/* ── MODALS ── */
.overlay{display:none;position:fixed;inset:0;background:rgba(10,12,30,.5);z-index:500;align-items:center;justify-content:center;backdrop-filter:blur(4px)}
.overlay.on{display:flex}
.modal{background:#fff;border-radius:14px;padding:24px;width:100%;max-width:480px;max-height:88vh;overflow-y:auto;box-shadow:0 20px 60px rgba(0,0,0,.2);animation:mIn .18s ease}
.modal.modal-lg{max-width:640px}
@keyframes mIn{from{opacity:0;transform:translateY(-8px) scale(.98)}to{opacity:1;transform:none}}
.modal-head{display:flex;align-items:center;margin-bottom:18px}
.modal-title{font-size:16px;font-weight:800;color:var(--ink)}
.modal-close{margin-left:auto;width:28px;height:28px;border:none;background:#f1f3f9;border-radius:6px;cursor:pointer;font-size:14px;display:flex;align-items:center;justify-content:center;transition:.12s}
.modal-close:hover{background:#e5e8f0}

/* Export buttons */
.export-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:14px}
.exp-btn{border:1px solid var(--border);border-radius:10px;padding:18px 12px;cursor:pointer;text-align:center;background:#fff;transition:.15s;display:flex;flex-direction:column;align-items:center;gap:6px}
.exp-btn:hover{border-color:var(--blue);background:var(--blue-lt)}
.exp-btn .ico{font-size:26px}
.exp-btn .lbl{font-size:13px;font-weight:700;color:var(--ink)}
.exp-btn .sub{font-size:11px;color:var(--sub)}

/* Templates */
.tpl-list{display:flex;flex-direction:column;gap:6px;max-height:260px;overflow-y:auto}
.tpl-item{display:flex;align-items:center;gap:8px;padding:8px 10px;border:1px solid var(--border);border-radius:7px;cursor:pointer;transition:.15s}
.tpl-item:hover,.tpl-item.on{border-color:var(--blue);background:var(--blue-lt)}
.tpl-name{flex:1;font-size:12px;font-weight:600}
.tpl-meta{font-size:11px;color:var(--sub)}
.tpl-del{width:20px;height:20px;background:none;border:none;cursor:pointer;color:var(--sub2);border-radius:4px;font-size:11px;display:flex;align-items:center;justify-content:center;transition:.12s}
.tpl-del:hover{background:#fee2e2;color:var(--red)}
.tpl-empty{font-size:12px;color:var(--sub2);text-align:center;padding:20px;font-style:italic}

/* Designs modal */
.design-modal-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.dm-item{border:2px solid var(--border);border-radius:10px;padding:12px;cursor:pointer;transition:.15s;background:#fff}
.dm-item:hover{border-color:var(--border2)}
.dm-item.on{border-color:var(--blue);background:var(--blue-lt)}
.dm-preview{height:36px;border-radius:6px;margin-bottom:8px}
.dm-name{font-size:13px;font-weight:700;color:var(--ink)}
.dm-desc{font-size:11px;color:var(--sub);margin-top:2px}

/* Toast */
.toast-area{position:fixed;bottom:20px;right:20px;z-index:9999;display:flex;flex-direction:column;gap:7px}
.toast{background:#1f2937;color:#fff;padding:9px 14px;border-radius:8px;font-size:12px;font-weight:500;display:flex;align-items:center;gap:7px;box-shadow:0 4px 16px rgba(0,0,0,.2);animation:tIn .25s ease;max-width:260px}
.toast.ok{background:#064e3b}.toast.err{background:#7f1d1d}.toast.warn{background:#78350f}
@keyframes tIn{from{opacity:0;transform:translateX(14px)}to{opacity:1;transform:none}}

/* Theme overrides */
/* Modern */
.theme-modern table.tt thead th{background:linear-gradient(90deg,#4361ee,#8b5cf6);color:#fff;border-color:rgba(255,255,255,.15)}
.theme-modern .tt-container{background:linear-gradient(135deg,#eef1fd,#f5f3ff)}
.theme-modern table.tt tbody td.tc{background:linear-gradient(135deg,#eef1fd,#ede9fe)}
/* Minimal */
.theme-minimal table.tt thead th{background:transparent;border-bottom:2px solid #000;color:#000;text-transform:none;font-size:13px;letter-spacing:0}
.theme-minimal table.tt tbody td{border:none;border-bottom:1px solid #f0f0f0}
.theme-minimal table.tt tbody td.tc{background:transparent;border:none;border-bottom:1px solid #f0f0f0}
/* Colorful */
.theme-colorful table.tt thead th:nth-child(2){background:#ffd6d6}
.theme-colorful table.tt thead th:nth-child(3){background:#d6ffe8}
.theme-colorful table.tt thead th:nth-child(4){background:#d6eaff}
.theme-colorful table.tt thead th:nth-child(5){background:#fff4d6}
.theme-colorful table.tt thead th:nth-child(6){background:#f0d6ff}
.theme-colorful table.tt thead th:nth-child(7){background:#d6f8ff}
.theme-colorful table.tt thead th:nth-child(8){background:#ffd6f5}
.theme-colorful table.tt thead th{color:#333}
/* Dark */
.theme-dark .tt-container,.theme-dark .tt-area{background:#111827}
.theme-dark table.tt thead th{background:#1f2937;color:#9ca3af;border-color:#374151}
.theme-dark table.tt tbody td{background:#111827;border-color:#1f2937;color:#e5e7eb}
.theme-dark table.tt tbody td:hover{background:#1a2234}
.theme-dark table.tt tbody td.tc{background:#1f2937;border-color:#374151;color:#6b7280}
/* Elegant */
.theme-elegant table.tt thead th{background:linear-gradient(90deg,#1e293b,#334155);color:#e2e8f0;border:none;font-size:11px}
.theme-elegant table.tt tbody td.tc{background:#f8f6f0;color:#78716c;border-right-color:#d6d3d1}
.theme-elegant .tt-container{border-color:#d6d3d1;box-shadow:0 4px 20px rgba(0,0,0,.1)}
/* Futuristic */
.theme-futuristic .tt-container{background:#0a0e1a;border-color:#1e3a5f}
.theme-futuristic table.tt thead th{background:linear-gradient(90deg,#0d1b2a,#1a3a5c);color:#38bdf8;border-color:#1e3a5f;text-shadow:0 0 8px #38bdf8}
.theme-futuristic table.tt tbody td{background:#0a0e1a;border-color:#1e3a5f;color:#e0f2fe}
.theme-futuristic table.tt tbody td:hover{background:#0d1b2a}
.theme-futuristic table.tt tbody td.tc{background:#0d1b2a;color:#38bdf8;border-right-color:#1e3a5f}
/* Nature */
.theme-nature table.tt thead th{background:linear-gradient(90deg,#14532d,#166534);color:#bbf7d0;border:none}
.theme-nature .tt-container{border-color:#bbf7d0;background:#f0fdf4}
.theme-nature table.tt tbody td.tc{background:#dcfce7;color:#166534}
/* Ocean */
.theme-ocean table.tt thead th{background:linear-gradient(90deg,#0c4a6e,#075985);color:#bae6fd;border:none}
.theme-ocean .tt-container{border-color:#bae6fd;background:#f0f9ff}
.theme-ocean table.tt tbody td.tc{background:#e0f2fe;color:#0369a1}
/* Vibrant */
.theme-vibrant table.tt thead th{background:linear-gradient(90deg,#dc2626,#ea580c,#d97706);color:#fff;border:none}
.theme-vibrant .tt-container{background:linear-gradient(135deg,#fff7f0,#fff0f3)}

@media print{
  .topbar,.left-col,.tt-toolbar,.toast-area,.overlay{display:none!important}
  .layout{display:block}
  .right-col{overflow:visible}
  .tt-area{padding:0}
  .tt-container{border:1px solid #ddd;box-shadow:none}
}
