:root {
  --navy-950: #071c31;
  --navy-900: #0b2f57;
  --navy-800: #104673;
  --navy-700: #1766a5;
  --blue-100: #eaf3fb;
  --blue-50: #f5f9fd;
  --gold: #c8a94b;
  --bg: #f3f6fa;
  --card: #ffffff;
  --text: #17212c;
  --muted: #687786;
  --line: #dce4ec;
  --success: #16805c;
  --success-bg: #e7f7f0;
  --warning: #a76700;
  --warning-bg: #fff3d8;
  --danger: #bd3434;
  --danger-bg: #fdeaea;
  --shadow: 0 10px 30px rgba(15, 42, 70, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: 270px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, var(--navy-950), var(--navy-900) 55%, #0b3f6b);
  color: white;
  padding: 22px 16px;
  box-shadow: 8px 0 30px rgba(3, 22, 40, 0.18);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 7px 24px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-logo { width: 54px; height: 54px; object-fit: contain; border-radius: 50%; background: rgba(255,255,255,.1); padding: 3px; }
.brand strong { display: block; font-size: 18px; letter-spacing: .2px; }
.brand small { display: block; margin-top: 2px; color: rgba(255,255,255,.65); font-size: 12px; }
.sidebar-nav { display: grid; gap: 7px; margin-top: 22px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px 13px; border-radius: 11px; color: rgba(255,255,255,.72); font-weight: 650; transition: .18s ease; }
.nav-link:hover { background: rgba(255,255,255,.08); color: white; transform: translateX(2px); }
.nav-link.active { background: rgba(255,255,255,.14); color: white; box-shadow: inset 3px 0 0 var(--gold); }
.nav-icon { width: 24px; text-align: center; font-size: 18px; }
.sidebar-footer { margin-top: auto; display: grid; gap: 14px; }
.admin-chip { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.09); padding: 11px; border-radius: 12px; }
.admin-chip strong, .admin-chip small { display: block; }
.admin-chip strong { font-size: 13px; }
.admin-chip small { color: rgba(255,255,255,.62); font-size: 11px; }
.avatar { width: 36px; height: 36px; flex: 0 0 36px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--gold); color: var(--navy-950); font-weight: 800; }
.main-content { margin-left: 270px; min-height: 100vh; }
.topbar { height: 92px; display: flex; align-items: center; gap: 16px; padding: 0 34px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 0; font-size: 23px; letter-spacing: -.3px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .55px; }
.sidebar-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line); background: white; border-radius: 10px; }
.page-content { padding: 28px 34px 50px; max-width: 1700px; margin: 0 auto; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(5, 19, 33, .55); }

h1, h2, h3, p { overflow-wrap: anywhere; }
h2 { margin: 0; font-size: 20px; letter-spacing: -.2px; }
h3 { margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { justify-content: flex-end !important; }
.eyebrow { display: block; color: var(--navy-700); font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: .9px; margin-bottom: 3px; }

.card { background: var(--card); border: 1px solid rgba(211, 221, 231, .9); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.card-header.wrap { flex-wrap: wrap; }
.card-footer { display: flex; justify-content: flex-end; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-card { max-width: 920px; margin: 0 auto; }
.form-card.narrow { max-width: 760px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { min-height: 135px; background: linear-gradient(145deg, white, #f9fbfd); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 80px; height: 80px; right: -25px; bottom: -30px; border-radius: 50%; background: var(--blue-100); }
.stat-label { display: block; font-size: 12px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .55px; }
.stat-card strong { display: block; margin: 7px 0 0; font-size: 33px; color: var(--navy-900); line-height: 1.1; }
.stat-card small { color: var(--muted); }
.compact-stats .stat-card { min-height: 118px; }

.content-grid { display: grid; gap: 20px; margin-bottom: 20px; }
.content-grid.two-one { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.content-grid.one-one { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack-lg { display: grid; gap: 20px; }
.stack-md { display: grid; gap: 14px; }

.period-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.period-overview > div { padding: 16px; background: var(--blue-50); border: 1px solid var(--line); border-radius: 12px; }
.period-overview span, .period-overview strong { display: block; }
.period-overview span { color: var(--muted); font-size: 12px; }
.period-overview strong { margin-top: 4px; font-size: 24px; color: var(--navy-900); }
.status-line { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.quick-actions { display: grid; align-content: start; }
.quick-actions a { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.quick-actions a:last-child { border-bottom: 0; }
.quick-actions a > span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; color: var(--navy-900); background: var(--blue-100); font-size: 20px; }
.quick-actions strong, .quick-actions small { display: block; }
.quick-actions small { color: var(--muted); margin-top: 2px; }

.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; min-height: 40px; font-weight: 750; font-size: 13px; transition: .15s ease; background: white; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 15px rgba(24, 56, 86, .10); }
.btn-primary { background: var(--navy-900); border-color: var(--navy-900); color: white; }
.btn-success { background: var(--success); border-color: var(--success); color: white; }
.btn-warning { background: var(--warning-bg); border-color: #efcf8f; color: var(--warning); }
.btn-outline { border-color: var(--line); color: var(--navy-900); background: white; }
.btn-danger-outline { border-color: #efbcbc; color: var(--danger); background: white; }
.btn-block { width: 100%; }
.btn-lg { min-height: 48px; font-size: 14px; }
.btn-sm { min-height: 32px; padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; border-radius: 9px; background: #edf2f7; font-size: 20px; }
.icon-btn.danger { color: var(--danger); background: var(--danger-bg); }
.lock-btn { border: 0; border-radius: 8px; background: #edf2f7; width: 36px; height: 34px; }
.lock-btn.locked { background: var(--blue-100); }

.page-actions, .schedule-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.toolbar-actions, .hero-actions, .export-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.toolbar-actions form, .hero-actions form, .actions form { display: inline-flex; margin: 0; }
.search-form { display: flex; gap: 8px; min-width: min(100%, 520px); }
.search-form input { flex: 1; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: white; }
th, td { text-align: left; padding: 12px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f7f9fc; color: #4d5e6e; font-size: 11px; text-transform: uppercase; letter-spacing: .45px; white-space: nowrap; }
td { font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td small { color: var(--muted); }
.actions { white-space: nowrap; text-align: right; }
.actions > * { margin-left: 4px; }
.schedule-table-wrap { max-height: 720px; }
.schedule-table thead { position: sticky; top: 0; z-index: 2; }
.row-warning { background: #fffaf0; }
.row-danger { background: #fff0f0; }
.total-chip, .count-chip { display: inline-flex; min-width: 34px; justify-content: center; padding: 5px 9px; border-radius: 999px; background: var(--blue-100); color: var(--navy-900); font-weight: 800; font-size: 12px; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 10px; font-weight: 850; letter-spacing: .45px; }
.badge-draft { color: #555f68; background: #edf0f2; }
.badge-approved { color: var(--success); background: var(--success-bg); }
.badge-revised { color: var(--warning); background: var(--warning-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-muted { color: #707b84; background: #eef1f3; }

.alert { padding: 13px 16px; border-radius: 11px; border: 1px solid; margin-bottom: 18px; font-size: 13px; font-weight: 650; transition: .3s ease; }
.alert-success { background: var(--success-bg); border-color: #afe3cf; color: #0c6849; }
.alert-danger { background: var(--danger-bg); border-color: #efb4b4; color: #9d2929; }
.alert-warning { background: var(--warning-bg); border-color: #e9ca87; color: #8a5908; }
.alert.fade-out { opacity: 0; transform: translateY(-5px); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.span-2 { grid-column: span 2; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 12px; font-weight: 780; color: #4c5b69; }
.field small { color: var(--muted); font-size: 11px; }
input, select, textarea { width: 100%; border: 1px solid #cfd9e3; border-radius: 10px; background: white; color: var(--text); padding: 10px 11px; outline: none; min-height: 42px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(23, 102, 165, .12); }
.input-suffix { display: flex; align-items: center; border: 1px solid #cfd9e3; border-radius: 10px; overflow: hidden; background: white; }
.input-suffix input { border: 0; border-radius: 0; box-shadow: none; }
.input-suffix span { padding: 0 12px; color: var(--muted); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 6px; padding-top: 17px; border-top: 1px solid var(--line); }
.check-card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); padding: 13px; border-radius: 11px; background: #fbfcfe; }
.check-card input { width: 18px; height: 18px; min-height: auto; margin-top: 2px; }
.check-card strong, .check-card small { display: block; }
.check-card small { color: var(--muted); margin-top: 2px; }
.info-box { border: 1px solid #cbdff1; background: var(--blue-50); color: #34546f; border-radius: 11px; padding: 13px 14px; font-size: 12px; }
.top-gap { margin-top: 18px; }
.disabled { opacity: .45; }

.import-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: center; }
.upload-box { border: 1px dashed #aebfce; background: #f8fafc; padding: 16px; border-radius: 12px; display: grid; gap: 12px; }
.logo-editor { display: flex; align-items: center; gap: 18px; padding: 16px; background: #f8fafc; border: 1px solid var(--line); border-radius: 13px; }
.logo-editor img { width: 90px; height: 90px; object-fit: contain; border-radius: 50%; background: white; border: 1px solid var(--line); padding: 5px; }
.logo-editor .field { flex: 1; }

.period-cards { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 16px; }
.period-card { display: grid; gap: 20px; border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: linear-gradient(150deg, #fff, #f8fbfe); }
.period-card h3 { font-size: 24px; color: var(--navy-900); margin-bottom: 10px; }
.period-card-meta { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 13px; font-size: 12px; color: var(--muted); }
.period-card-meta strong { color: var(--text); }
.period-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; background: linear-gradient(130deg, var(--navy-950), var(--navy-800)); color: white; border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.period-hero .eyebrow { color: #a9d1ef; }
.period-hero h2 { font-size: 28px; }
.period-hero .status-line { color: rgba(255,255,255,.72); }

.selection-list { max-height: 620px; overflow-y: auto; display: grid; gap: 8px; padding-right: 4px; }
.person-select { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcfe; cursor: pointer; }
.person-select:hover { border-color: #b6c9db; background: var(--blue-50); }
.person-select input { width: 17px; height: 17px; min-height: auto; }
.person-select strong, .person-select small { display: block; }
.person-select small { color: var(--muted); }
.timeline { display: grid; gap: 14px; }
.timeline-item { display: flex; gap: 11px; }
.timeline-item > span { margin-top: 5px; width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: var(--navy-700); box-shadow: 0 0 0 4px var(--blue-100); }
.timeline-item strong, .timeline-item small { display: block; }
.timeline-item small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.danger-zone { border-color: #f0c5c5; }
.danger-zone h2 { color: var(--danger); }
.danger-zone p { color: var(--muted); font-size: 12px; }

.exception-list { display: grid; gap: 10px; }
.exception-card { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.exception-symbol { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 50%; font-size: 20px; font-weight: 900; }
.exception-symbol.hard { background: var(--danger-bg); color: var(--danger); }
.exception-symbol.soft { background: var(--warning-bg); color: var(--warning); }
.exception-body { flex: 1; min-width: 0; }
.exception-body > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exception-body p { margin: 4px 0 0; font-size: 12px; }
.exception-body small { color: var(--muted); }

.empty-state { text-align: center; padding: 45px 20px; }
.empty-state.full { grid-column: 1 / -1; }
.empty-state.compact { padding: 28px 16px; }
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 13px; border-radius: 50%; background: var(--blue-100); color: var(--navy-900); font-size: 25px; font-weight: 900; }
.empty-state p { color: var(--muted); max-width: 500px; margin: 7px auto 17px; }
.empty-inline { text-align: center; color: var(--muted); padding: 26px; }
.error-state { min-height: 60vh; display: grid; place-content: center; }

.modal { border: 0; padding: 0; background: transparent; max-width: min(92vw, 610px); width: 100%; }
.modal::backdrop { background: rgba(5, 20, 34, .58); backdrop-filter: blur(2px); }
.modal-card { background: white; border-radius: 16px; box-shadow: 0 25px 80px rgba(0,0,0,.25); padding: 22px; }
.modal-header, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.modal-header { margin-bottom: 18px; }
.modal-actions { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); justify-content: flex-end; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 520px) 1fr; background: white; }
.login-panel { padding: clamp(30px, 7vw, 90px); display: flex; flex-direction: column; justify-content: center; }
.login-brand { display: flex; align-items: center; gap: 15px; margin-bottom: 38px; }
.login-brand img { width: 76px; height: 76px; object-fit: contain; }
.login-brand span { color: var(--navy-700); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.login-brand h1 { margin: 2px 0 0; color: var(--navy-900); font-size: 32px; }
.login-brand p { color: var(--muted); margin: 0; }
.login-help { margin-top: 22px; background: var(--blue-50); border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--muted); font-size: 12px; }
.login-art { display: flex; align-items: flex-end; padding: 70px; background: linear-gradient(rgba(6, 30, 54, .73), rgba(7, 34, 61, .92)), radial-gradient(circle at 70% 20%, #2b83c4, #082946 58%, #04182b); color: white; position: relative; overflow: hidden; }
.login-art::before { content: ""; position: absolute; inset: 8% 8% auto auto; width: 260px; height: 260px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; box-shadow: 0 0 0 55px rgba(255,255,255,.035), 0 0 0 110px rgba(255,255,255,.025); }
.login-art-content { max-width: 690px; position: relative; }
.login-art .eyebrow { color: #a9d4f0; }
.login-art h2 { font-size: clamp(35px, 4.5vw, 62px); line-height: 1.04; letter-spacing: -1.7px; margin: 10px 0 18px; }
.login-art p { color: rgba(255,255,255,.75); font-size: 16px; max-width: 600px; }
.feature-pills { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 24px; }
.feature-pills span { border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: 7px 12px; font-size: 12px; background: rgba(255,255,255,.07); }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .period-cards { grid-template-columns: repeat(2, 1fr); }
  .content-grid.two-one, .content-grid.one-one { grid-template-columns: 1fr; }
  .login-art { padding: 45px; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-backdrop { display: block; }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: inline-grid; place-items: center; }
  .topbar { height: 78px; padding: 0 18px; }
  .topbar p { display: none; }
  .page-content { padding: 20px 16px 40px; }
  .period-hero { align-items: flex-start; flex-direction: column; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-panel { padding: 35px 24px; }
}

@media (max-width: 590px) {
  .stats-grid, .period-cards, .period-overview { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .import-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .page-actions, .schedule-toolbar { align-items: stretch; }
  .toolbar-actions, .hero-actions, .export-actions { width: 100%; }
  .toolbar-actions > *, .hero-actions > *, .export-actions > * { flex: 1 1 auto; }
  .search-form { min-width: 100%; }
  .logo-editor { align-items: flex-start; flex-direction: column; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

@media print {
  .sidebar, .topbar, .page-actions, .schedule-toolbar, .compact-stats, .export-actions, .no-copy, .sidebar-backdrop { display: none !important; }
  .main-content { margin: 0; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .table-wrap { overflow: visible; border: 0; }
  table { min-width: 0; }
}

[data-duty-drag] { cursor: grab; display: inline-block; border-bottom: 1px dashed currentColor; }
[data-duty-drag]:active { cursor: grabbing; }
[data-duty-drag]:focus-visible { outline: 2px solid #2474b9; outline-offset: 4px; }
.schedule-table tr.drop-target { background: #dcefff; outline: 2px solid #2474b9; outline-offset: -2px; }
.history-entry { padding: 14px 0; border-bottom: 1px solid #dfe5ec; }
.history-entry summary { cursor: pointer; line-height: 1.6; }
.history-entry li { margin: 8px 0; }
