/* TBS SIOS web edition */
:root {
    --bg: #F5F7FA;
    --card: #FFFFFF;
    --border: #D8E0E8;
    --text: #10233D;
    --muted: #64748B;
    --primary: #0B3B75;
    --primary-dark: #082B56;
    --accent: #3B95D2;
    --green: #2E7D32;
    --amber: #B8860B;
    --red: #C62828;
    --grey: #6C757D;
    --gold: #D4AF37;
    --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.45;
}
a { color: var(--primary); }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; }
code { background: #EEF2F6; padding: 1px 5px; border-radius: 4px; }

/* Header */
.topbar {
    display: flex; align-items: center; gap: 14px;
    background: var(--primary); color: #fff; padding: 10px 18px;
    position: sticky; top: 0; z-index: 20;
}
.topbar .logo { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.brand-title { font-size: 19px; font-weight: 700; }
.brand-sub { font-size: 13px; color: #D8E6F3; }
.topbar-user { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 14px; }
.topbar-user a { color: #D8E6F3; text-decoration: none; }
.topbar-user a:hover { color: #fff; text-decoration: underline; }
.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }

/* Layout */
.shell { display: flex; min-height: calc(100vh - 68px - 32px); }
.sidebar {
    width: 240px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
    padding: 10px 10px 30px; overflow-y: auto;
}
.nav-section { font-weight: 700; font-size: 14px; margin: 16px 8px 6px; color: var(--text); }
.nav-link {
    display: block; padding: 8px 12px; margin: 2px 0; border-radius: 8px; text-decoration: none;
    color: var(--text); font-size: 14px;
}
.nav-link:hover { background: #EEF4F9; }
.nav-link.active { background: var(--primary); color: #fff; }
.content { flex: 1; padding: 22px 26px 40px; min-width: 0; }
.statusbar { background: #fff; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; padding: 7px 18px; }

/* Cards & grids */
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; margin-bottom: 18px;
}
.card.narrow { max-width: 560px; }
.card.info { background: #EAF2F8; border-color: #C9D9E8; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mini-card { background: #FAFBFC; border: 1px solid #E3E8EE; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.mini-card.highlighted { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(11, 59, 117, .15); }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid > .card, .grid > .mini-card { margin-bottom: 0; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.banner { background: var(--primary); color: #fff; border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px; }
.banner p { color: #D9E5F2; margin: 4px 0 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { font-size: 18px; font-weight: 600; }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-blue { color: var(--primary); }
.text-grey { color: var(--grey); }

/* Metrics */
.metric-card { display: flex; flex-direction: column; gap: 4px; }
.metric-title { font-weight: 700; font-size: 16px; }
.metric-value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.metric-rating { font-weight: 600; }
.live-dot { color: var(--green); font-weight: 600; }
.health { background: #E8F0F8; border-radius: 8px; padding: 10px 12px; font-size: 13px; }

/* Progress */
.progress { background: #E8EDF3; border-radius: 99px; height: 14px; overflow: hidden; margin: 8px 0; }
.progress-bar { background: var(--accent); height: 100%; border-radius: 99px; }

/* Pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-green { background: #DFF2E3; color: #155724; }
.pill-amber { background: #FFF3CD; color: #856404; }
.pill-red { background: #F8D7DA; color: #721C24; }
.pill-grey { background: #E9ECEF; color: #495057; }
.tag { display: inline-block; font-size: 11px; background: #EEF4F9; color: var(--primary); border-radius: 5px; padding: 1px 6px; }

/* Buttons */
.btn {
    display: inline-block; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer;
    background: #E8EDF3; color: var(--text); font: inherit; font-weight: 600; text-decoration: none; text-align: center;
}
.btn:hover { filter: brightness(.95); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); filter: none; }
.btn-grey { background: #5C6F82; color: #fff; }
.btn-red { background: #A83232; color: #fff; }
.btn-gold { background: var(--gold); color: #1F1F1F; }
.btn-small { padding: 5px 11px; font-size: 13px; }
.btn-block { display: block; width: 100%; margin: 6px 0; }

/* Forms */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url],
input[type=search], input[type=file], select, textarea {
    font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--text); width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(59, 149, 210, .4); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.form-actions.left { justify-content: flex-start; margin-bottom: 8px; }
.form-actions form { margin: 0; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form label { margin-bottom: 0; }
.inline-form input[type=search] { min-width: 280px; width: auto; }
.inline-form select { width: auto; }
.schedule { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.schedule legend { font-weight: 700; color: var(--primary); }
.save-bar { display: flex; justify-content: flex-end; margin: -6px 0 18px; }
.error-text { color: var(--red); margin: 6px 0; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; }
.flash-success { background: #DFF2E3; color: #155724; }
.flash-error { background: #F8D7DA; color: #721C24; }
.flash-info { background: #E8F0F8; color: var(--primary); }

/* Accordions */
.accordion { background: #fff; border: 1px solid #DCE3EA; border-radius: var(--radius); margin-bottom: 14px; }
.accordion > summary {
    list-style: none; cursor: pointer; padding: 14px 18px; display: flex; gap: 12px; align-items: center;
    font-weight: 700; font-size: 16px;
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::before { content: "▶"; font-size: 11px; color: var(--muted); }
.accordion[open] > summary::before { content: "▼"; }
.accordion > summary small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: auto; }
.accordion-body { padding: 4px 18px 18px; border-top: 1px solid #F1F5F9; }

/* Monitoring */
.stage-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; padding-top: 14px; }
.stage-card { border: 1px solid; border-radius: 10px; padding: 10px; }
.stage-num { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; color: #fff; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 4px; }
.week-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; padding-top: 12px; }
.week-btn {
    color: #fff; text-decoration: none; text-align: center; border-radius: 8px; padding: 6px 2px; font-size: 12px; line-height: 1.25;
    border: 3px solid transparent;
}
.week-btn:hover { filter: brightness(.9); }
.week-btn.selected { border-color: var(--gold); }
.week-info { border-left: 6px solid var(--primary); background: #F7F9FB; padding: 10px 14px; border-radius: 8px; margin: 12px 0; }
.week-info h3 { margin-top: 0; }
.checkpoint { border: 1px solid #DCE3EA; border-radius: 10px; padding: 14px; margin: 12px 0; background: #fff; }
.checkpoint.planned { background: #FFF9E8; border-color: #E5C76B; }
.checkpoint-head { display: flex; justify-content: space-between; gap: 10px; color: var(--primary); }
.detail-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; background: #F5F7FA; border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.row-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #F5F7FA; border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.empty { background: #F7F9FB; border: 1px dashed var(--border); border-radius: 10px; padding: 14px; }
.drilldown { border: 1px solid var(--primary); border-radius: 10px; padding: 12px 14px; }

/* Activity */
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 6px; border-bottom: 1px solid #F1F5F9; }
.activity a { text-decoration: none; color: var(--text); }

/* SDP */
.priority-card > summary { align-items: flex-start; }
.priority-num { background: var(--primary); color: #fff; border-radius: 10px; min-width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.priority-title { display: flex; flex-direction: column; flex: 1; }
.priority-title small { font-weight: 400; color: var(--muted); font-size: 13px; margin: 2px 0 0 !important; }
.priority-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 360px; }
.action-card { display: flex; gap: 12px; border: 1px solid #E3E8EE; border-radius: 10px; padding: 12px; margin: 10px 0; }
.action-num { background: #E8EDF3; color: var(--primary); font-weight: 700; border-radius: 8px; min-width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.action-body { flex: 1; }
.action-body p { margin: 0 0 6px; }
.action-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.progress-form { margin: 0; }
.progress-form label { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.progress-form input[type=range] { width: 160px; }

/* Evidence */
.evidence-row { display: flex; justify-content: space-between; gap: 16px; background: #F8FAFC; border: 1px solid #E3E8EE; border-radius: 10px; padding: 12px; margin: 10px 0; }
.evidence-main { flex: 1; }
.evidence-main p { margin: 6px 0; }
.evidence-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; min-width: 150px; }
.evidence-side form { margin: 0; }
.evidence-side label { margin: 0; }
.chart-card { background: #fff; border: 1px solid #E3E8EE; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.chart-card h3 { margin-top: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #EEF2F6; vertical-align: top; }
.table thead th { background: var(--primary); color: #fff; font-weight: 600; position: sticky; top: 0; }
.table tbody tr:nth-child(even) { background: #F7F9FC; }
.table tr.inactive td { color: var(--muted); }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.cell-alert { background: #F8D7DA; color: #721C24; font-weight: 700; }
.rhythm th[scope], .rhythm tbody th { color: var(--primary); }

/* Login */
body.bare { background: linear-gradient(160deg, #0B3B75, #082B56); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 30px 34px; width: 100%; max-width: 400px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.login-card input { margin: 8px 0; }
.login-logo { width: 90px; height: 90px; object-fit: contain; }
body.bare .flash { max-width: 400px; margin: 20px auto -10px; }

/* Responsive */
@media (max-width: 1100px) {
    .grid-4, .grid-6 { grid-template-columns: repeat(2, 1fr); }
    .grid-3, .grid-2-1 { grid-template-columns: 1fr; }
    .stage-grid { grid-template-columns: repeat(2, 1fr); }
    .week-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 800px) {
    .menu-toggle { display: block; }
    .brand-sub, .topbar-user span { display: none; }
    .sidebar { position: fixed; top: 68px; bottom: 0; left: -260px; z-index: 30; transition: left .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
    body.nav-open .sidebar { left: 0; }
    .content { padding: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .detail-row { grid-template-columns: 1fr 1fr; }
    .evidence-row, .row-item { flex-direction: column; align-items: stretch; }
    .evidence-side { align-items: flex-start; }
    .inline-form input[type=search] { min-width: 0; width: 100%; }
}
