
:root {
  --red: #E0191E;
  --red-dark: #B5121B;
  --red-tint: #FDECEC;
  --ink: #1E1E1E;
  --text: #374151;
  --muted: #6B7280;
  --line: #E5E7EB;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --green: #15803D;
  --green-tint: #DCFCE7;
  --amber: #B45309;
  --amber-tint: #FEF3C7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: 'Poppins', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
a { color: var(--red); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 42px; height: 42px; border-radius: 10px; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; letter-spacing: .5px; overflow: hidden; flex: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { font-weight: 700; color: var(--ink); font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { padding: 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--red-tint); color: var(--red-dark); }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.page { padding: 28px 32px 48px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 12px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1.4fr 1fr; }
.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--red-tint); color: var(--red); }
.stat-icon.g { background: var(--green-tint); color: var(--green); }
.stat-icon.a { background: var(--amber-tint); color: var(--amber); }
.stat-icon.n { background: #EEF2FF; color: #4338CA; }
.stat b { display: block; font-size: 24px; color: var(--ink); line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-danger { color: var(--red-dark); border-color: #F5C2C4; }
.btn-danger:hover { background: var(--red-tint); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-ghost { border-color: transparent; background: transparent; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 500; color: var(--ink); font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=search], select, textarea {
  height: 40px; padding: 0 12px; border: 1px solid #D1D5DB; border-radius: 8px; font: inherit; color: var(--ink); background: #fff; width: 100%;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(224, 25, 30, .25); border-color: var(--red); }
input[type=color] { width: 48px; height: 40px; padding: 2px; border: 1px solid #D1D5DB; border-radius: 8px; background: #fff; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 22px; background: #D1D5DB; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid rgba(224,25,30,.35); outline-offset: 2px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-tint); color: var(--green); }
.badge.red { background: var(--red-tint); color: var(--red-dark); }
.badge.amber { background: var(--amber-tint); color: var(--amber); }
.badge.dark { background: #222; color: #fff; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #FAFAFB; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .name { font-weight: 600; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.right { text-align: right; }
.days { display: flex; gap: 4px; }
.day-dot { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--bg); color: #9CA3AF; }
.day-dot.on { background: var(--red-tint); color: var(--red-dark); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg.i { width: 36px; height: 36px; color: #D1D5DB; margin-bottom: 8px; }
.alert { padding: 12px 16px; border-radius: 10px; display: flex; gap: 12px; align-items: flex-start; }
.alert.amber { background: var(--amber-tint); color: #78350F; border: 1px solid #FDE68A; }
.alert.red { background: var(--red-tint); color: var(--red-dark); border: 1px solid #F5C2C4; }
.alert.info { background: #EFF6FF; color: #1E3A8A; border: 1px solid #BFDBFE; }

/* roster list */
.roster-group { padding: 6px 20px 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--red-dark); background: #FAFAFB; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); }
.roster-group:first-child { border-top: 0; }
.roster-item { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.roster-item:last-child { border-bottom: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--red-tint); color: var(--red-dark); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.roster-item .who { flex: 1; min-width: 0; }
.roster-item .who b { color: var(--ink); display: block; font-weight: 600; }
.time-pill { font-weight: 600; color: var(--ink); background: var(--bg); padding: 4px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap; }

.date-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-bar input[type=date] { width: 170px; }
.weekday-chip { font-weight: 600; color: var(--red-dark); background: var(--red-tint); padding: 8px 12px; border-radius: 8px; }

/* schedule editor */
.sched { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sched-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: start; }
.sched-row:last-child { border-bottom: 0; }
.sched-row.off { background: #FAFAFB; }
.sched-row.off .sessions { opacity: .45; }
.sessions { display: flex; flex-direction: column; gap: 6px; }
.session { display: flex; align-items: center; gap: 8px; }
.session input[type=time] { width: 130px; height: 36px; }
.sched-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(17, 24, 39, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.sm { max-width: 440px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-error { margin-bottom: 14px; }

/* toast */
.toasts { position: fixed; right: 20px; bottom: 20px; pointer-events: none; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.2); display: flex; gap: 10px; align-items: center; max-width: 380px; animation: tin .2s ease-out; }
.toast.err { background: var(--red-dark); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* post generator */
.gen { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.gen-controls { display: flex; flex-direction: column; gap: 18px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; padding: 4px; gap: 4px; background: var(--bg); }
.seg button { border: 0; background: transparent; padding: 8px; border-radius: 7px; font: inherit; font-weight: 500; cursor: pointer; color: var(--muted); line-height: 1.3; }
.seg button small { display: block; font-size: 11px; font-weight: 400; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.preview-wrap { background: #E9EBEF; border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.preview-wrap canvas { width: 100%; max-width: 560px; height: auto; box-shadow: 0 10px 30px rgba(0,0,0,.18); border-radius: 4px; background: #fff; }
.page-tabs { display: flex; gap: 6px; }

/* settings */
.logo-box { width: 120px; height: 120px; border: 1px dashed #D1D5DB; border-radius: 12px; display: grid; place-items: center; background: #fff; overflow: hidden; color: var(--muted); font-size: 12px; text-align: center; flex: none; }
.logo-box img { max-width: 100%; max-height: 100%; }
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type=text] { width: 120px; }

/* login */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art { background: linear-gradient(150deg, var(--red) 0%, var(--red-dark) 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::before, .login-art::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.07); }
.login-art::before { width: 520px; height: 520px; right: -180px; top: -140px; }
.login-art::after { width: 360px; height: 360px; left: -120px; bottom: -120px; }
.login-art h1 { color: #fff; font-size: 34px; max-width: 420px; position: relative; }
.login-art p { opacity: .85; max-width: 420px; position: relative; }
.login-form-wrap { display: grid; place-items: center; padding: 32px; background: #fff; }
.login-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .gen { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .page { padding: 20px 16px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .sched-row { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table.responsive td { display: block; border: 0; padding: 4px 16px; }
}
