:root {
    --font-ui: "Segoe UI", Tahoma, Arial, sans-serif;
    --bg-page: #f1f4f9;
    --bg-muted: #eef3f9;
    --text: #1d3047;
    --text-muted: #5f7288;
    --border: #d4deea;
    --border-soft: #e5ebf3;
    --white: #ffffff;
    --primary-950: #0b1e36;
    --primary-900: #102743;
    --primary-800: #17375d;
    --primary-700: #285481;
    --primary-500: #3b6fa2;
    --gold-500: #c89b3c;
    --gold-600: #b4872f;
    --success: #207d60;
    --danger: #b74046;
    --warning: #b7771f;
    --info: #2f6aa3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-ui);
    background:
        radial-gradient(circle at top right, #e0e8f4 0, transparent 36%),
        radial-gradient(circle at bottom left, #e7edf6 0, transparent 42%),
        var(--bg-page);
    color: var(--text);
}

a { color: #204f7c; text-decoration: none; }
a:hover { color: #173d62; }

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 286px;
    padding: 1.35rem 1.1rem;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.05), transparent 40%),
        linear-gradient(180deg, var(--primary-800) 0%, var(--primary-950) 100%);
    color: #edf5ff;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid rgba(255,255,255,0.12);
}

.brand {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.14);
}

.brand-shell {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    background: rgba(255,255,255,0.97);
    border-radius: 10px;
    padding: 0.25rem;
    box-shadow: 0 8px 18px rgba(6, 19, 34, 0.22);
    flex: 0 0 auto;
}

.brand-title {
    font-size: 1.02rem;
    font-weight: 700;
    margin-bottom: 0.18rem;
}

.brand-subtitle {
    font-size: 0.82rem;
    color: #bdd0e5;
    line-height: 1.45;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav a {
    color: #d9e8f6;
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    transition: all 0.16s ease;
}

.nav a:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.14);
    color: #fff;
}

.nav a.active {
    background: linear-gradient(90deg, rgba(200,155,60,0.28), rgba(255,255,255,0.08));
    border-color: rgba(205,169,92,0.38);
    color: #fff;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 1.2rem 1.5rem 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 4px 18px rgba(28,49,73,0.06);
}

.topbar-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.topbar-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    padding: 0.22rem;
    border: 1px solid #d7e2ee;
}

.topbar h1 {
    margin: 0;
    font-size: 1.35rem;
    color: #17324d;
}

.topbar-subtitle {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.user-pill {
    border: 1px solid #cfdae8;
    color: #334a63;
    background: #f2f7fc;
    border-radius: 999px;
    padding: 0.38rem 0.7rem;
    font-size: 0.82rem;
    white-space: nowrap;
}

.page-intro,
.card {
    position: relative;
    overflow: hidden;
}

.page-intro::before,
.card::before {
    content: "";
    display: block;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--gold-500), var(--primary-500), rgba(59,111,162,0.22));
}

.page-intro {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    background: linear-gradient(140deg, #ffffff 0%, #f6f9fd 100%);
    box-shadow: 0 4px 14px rgba(17,33,55,0.05);
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.9rem;
}

.page-title-small {
    margin: 0 0 0.2rem;
    font-size: 1.02rem;
    color: #1b3553;
    font-weight: 700;
}

.page-subtitle-small,
.muted {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.ops-chip-row,
.actions {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    align-items: center;
}

.ops-chip {
    border: 1px solid #dbe4ef;
    background: #f5f8fc;
    color: #2d4a66;
    border-radius: 999px;
    padding: 0.32rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 650;
}

.ops-chip strong { color: #17324d; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 1rem;
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 4px 16px rgba(19,35,56,0.05);
}

.metric-card strong {
    display: block;
    font-size: 1.55rem;
    margin-bottom: 0.38rem;
    color: #173550;
}

.card h2, .card h3 {
    margin-top: 0;
    color: #1e3955;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 1rem;
}

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

th, td {
    border-bottom: 1px solid #e3ebf4;
    text-align: left;
    padding: 0.85rem 0.75rem;
    vertical-align: top;
}

th {
    background: linear-gradient(180deg, #edf3fb 0%, #f5f8fd 100%);
    color: #3a536d;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

tr:nth-child(even) td {
    background: #fbfdff;
}

tr:hover td {
    background: #edf5fe;
}

.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.stack-form {
    display: grid;
    gap: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-grid .full { grid-column: 1 / -1; }

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: #385470;
    font-weight: 600;
}

input, select, textarea, button {
    font: inherit;
    padding: 10px;
    border: 1px solid #cbd7e5;
    border-radius: 10px;
}

textarea { min-height: 96px; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #7396bf;
    box-shadow: 0 0 0 0.16rem rgba(59,111,162,0.17);
}

button, .button-link {
    background: linear-gradient(180deg, #2d5b8a, #214a74);
    color: #fff;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 10px;
    font-weight: 600;
}

.button-link.secondary {
    background: linear-gradient(180deg, #7b8da4, #687a90);
}

.button-link:hover, button:hover {
    filter: brightness(0.98);
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.28rem 0.62rem;
    font-size: 0.75rem;
    font-weight: 650;
    background: #dce9f7;
    color: #1f4f7f;
    border: 1px solid transparent;
}

.badge-secondary {
    background: #edf1f5;
    color: #5f6f82;
    border-color: #dde5ed;
}

.badge-success, .status-active {
    background: #e7f6ef;
    color: #1f7a57;
    border-color: #c2e7d8;
}

.badge-danger, .status-cancelled, .task-overdue {
    background: #fdeced;
    color: #b13d43;
    border-color: #f0c1c5;
}

.status-draft, .status-todo {
    background: #fff4df;
    color: #976116;
    border-color: #efd7a6;
}

.status-planned,
.status-info {
    background: #eaf4ff;
    color: #24639f;
    border-color: #c9ddf3;
}

.status-completed {
    background: #ece8ff;
    color: #4c3d99;
    border-color: #d5cdfb;
}

.simple-list {
    margin: 0;
    padding-left: 18px;
}

.simple-list li + li {
    margin-top: 0.5rem;
}

.activity-list li {
    padding-left: 0.2rem;
}

.day-group {
    padding: 0.9rem 0;
    border-bottom: 1px solid #e5e9ef;
}

.day-group:last-child {
    border-bottom: 0;
}

.calendar-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.calendar-title {
    margin: 0 0 0.2rem;
    font-size: 1.2rem;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.calendar-weekday {
    background: #eef4fb;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #35516d;
    text-align: center;
}

.calendar-day,
.calendar-cell {
    min-height: 150px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.65rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.calendar-day.muted,
.calendar-cell.is-outside-month {
    background: #f6f8fb;
    color: #8191a3;
}

.calendar-day.today,
.calendar-cell.is-today {
    border-color: #8bb0d8;
    box-shadow: inset 0 0 0 1px rgba(59,111,162,0.18);
}

.calendar-day-head,
.calendar-cell-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.calendar-day-number {
    font-size: 0.98rem;
}

.calendar-add-link {
    font-size: 0.77rem;
    font-weight: 700;
}

.calendar-day-events,
.calendar-events {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.calendar-event {
    border: 1px solid #d8e4f0;
    border-left-width: 4px;
    border-radius: 10px;
    padding: 0.45rem 0.5rem;
    background: #fbfdff;
}

.calendar-event-link {
    display: block;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 0.32rem;
}

.calendar-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.28rem;
}

.calendar-event-time {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.notice {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
}

.success {
    background: #e4f5e8;
    color: #115c36;
    border-color: #c6e8d0;
}

.error-box {
    background: #fde9e7;
    color: #a12626;
    border-color: #f3c5bf;
}

.error { color: #b42318; }

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: radial-gradient(circle at top left, #dce9f8 0%, #eaf2fb 45%, #f6f9fd 100%);
}

.login-card {
    width: min(420px, 92vw);
}

.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.login-logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    background: #fff;
    border-radius: 14px;
    padding: 0.35rem;
    border: 1px solid var(--border);
    box-shadow: 0 10px 24px rgba(19,35,56,0.08);
}

.login-subtitle {
    color: var(--text-muted);
    margin-top: 0;
    margin-bottom: 1rem;
}

.print-page {
    padding: 24px;
    background: #fff;
    color: #1c2d40;
}

.print-brand {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 1rem;
}

.inline-print-brand {
    margin-bottom: 1rem;
}

.print-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    background: #fff;
    border: 1px solid #d8e2ee;
    border-radius: 10px;
    padding: 4px;
}

@media (max-width: 980px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.12);
    }

    .main {
        padding: 1rem 0.9rem 1.5rem;
    }

    .two-col,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .calendar-weekdays,
    .calendar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .topbar {
        padding: 0.9rem;
        align-items: flex-start;
    }

    .topbar-head {
        width: 100%;
    }

    .topbar-logo {
        width: 42px;
        height: 42px;
    }

    .brand-logo {
        width: 48px;
        height: 48px;
    }

    .user-pill {
        white-space: normal;
    }

    .inline-form,
    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .button-link,
    button {
        width: 100%;
    }

    table {
        min-width: 640px;
    }

    .card {
        overflow-x: auto;
    }

    .calendar-toolbar {
        flex-direction: column;
    }

    .calendar-weekdays,
    .calendar-grid {
        grid-template-columns: 1fr;
    }
}
