:root {
    --bg-page: #111827;
    --bg-sheet: #1f2937;
    --color-primary: #8b5cf6;
    --color-primary-soft: #4c1d95;
    --color-primary-strong: #a78bfa;
    --color-accent: #f59e0b;
    --color-grid-border: #374151;
    --color-text-main: #e5e7eb;
    --color-text-muted: #9ca3af;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at top, #1e2640 0%, #111827 70%, #0f172a 100%);
    font-family: var(--font-main);
    color: var(--color-text-main);
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #0f172a;
    border-bottom: 1px solid var(--color-grid-border);
    padding: 12px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand-title {
    font-size: 20px;
    font-weight: 700;
}

.brand-subtitle {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
}

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tab-button {
    border: 1px solid var(--color-grid-border);
    background: #1f2937;
    color: var(--color-text-main);
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
    min-width: 120px;
    font-weight: 700;
}

.tab-button:hover {
    background: #2c344d;
}

.tab-button:active {
    transform: scale(0.98);
}

.tab-button.active {
    background: linear-gradient(90deg, var(--color-primary-soft), var(--color-primary));
    border-color: var(--color-primary-strong);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.page {
    width: 100%;
    max-width: 1400px;
    margin: 18px auto;
    padding: 0 16px 32px;
    flex: 1;
}

.card {
    background: #1f2937;
    border: 1px solid var(--color-grid-border);
    border-radius: 16px;
    padding: 18px 18px 22px;
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.4);
}

.card h2 {
    margin: 0 0 8px 0;
}

.card.wide {
    padding: 0;
    overflow: hidden;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.flutter-embed {
    margin-top: 14px;
    border: 1px solid var(--color-grid-border);
    border-radius: 14px;
    overflow: hidden;
    background: #0b1222;
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.4);
}

.flutter-embed iframe {
    width: 100%;
    min-height: 640px;
    border: 0;
    background: #0b1222;
}

.flutter-status {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-grid-border);
    font-weight: 700;
    color: var(--color-text-muted);
}

.flutter-status[data-tone="ready"] {
    color: #10b981;
}

.flutter-status[data-tone="error"] {
    color: #f87171;
}

.muted {
    color: var(--color-text-muted);
}

.list {
    padding-right: 18px;
    margin: 10px 0 0 0;
    line-height: 1.5;
}

.timeline {
    border-right: 2px solid var(--color-primary);
    padding-right: 14px;
    display: grid;
    gap: 12px;
}

.timeline-item {
    background: #202a3d;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--color-grid-border);
}

.timeline-time {
    color: var(--color-primary-strong);
    font-weight: 700;
    margin-bottom: 4px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.inventory-card {
    background: #202a3d;
    border: 1px solid var(--color-grid-border);
    border-radius: 12px;
    padding: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.sheet {
    max-width: 1280px;
    margin: 0 auto;
    background: var(--bg-sheet);
    padding: 24px 24px 32px;
    border-radius: 12px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
    border: 1px solid var(--color-grid-border);
    box-sizing: border-box;
    backdrop-filter: blur(2px);
}

.day-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
    letter-spacing: 0.04em;
    color: var(--color-primary);
}

.patient-header {
    position: relative;
    background: linear-gradient(90deg, var(--color-primary-soft), var(--color-primary));
    color: #ffffff;
    border-radius: 10px;
    padding: 18px 20px 20px;
    margin-bottom: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.patient-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.2), transparent 70%);
    opacity: 0.25;
    pointer-events: none;
}

.patient-header-main {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) 120px;
    column-gap: 18px;
    align-items: flex-start;
}

.info-block {
    font-size: 11px;
    color: var(--color-text-main);
}

.info-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 6px;
    opacity: 0.95;
}

.info-title::after {
    content: "";
    display: block;
    margin-top: 3px;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.1));
}

.field-row {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin: 3px 0;
    white-space: nowrap;
    align-items: flex-end;
}

.field-label {
    font-weight: 600;
    font-size: 11px;
    opacity: 0.95;
}

.field-value {
    flex: 1;
    min-width: 40px;
}

.field-input {
    width: 100%;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    background: transparent;
    color: #ffffff;
    font-size: 11px;
    padding: 0 0 1px 0;
    text-align: right;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}

.field-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.field-input:focus {
    border-bottom-color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.patient-weight .field-input {
    font-weight: 700;
}

.problem-list-box {
    margin-top: 6px;
    border-radius: 4px;
    border: 1px solid rgba(248, 250, 252, 0.6);
    min-height: 48px;
    padding: 4px 6px;
    box-sizing: border-box;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.18), rgba(15, 23, 42, 0.12));
}

.problem-list-line {
    border-bottom: 1px dotted rgba(226, 232, 240, 0.55);
    height: 10px;
    margin-bottom: 3px;
}

.problem-list-line:last-child {
    border-bottom: none;
}

.icon-block {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
}

.icon-box {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    border: 2px solid #ffffff;
    background: radial-gradient(circle at top, #43335f, #1f1533);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin-top: 10px;
}

.dog-icon {
    font-size: 34px;
    line-height: 1;
}

.time-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 11px;
    border-radius: 6px;
    overflow: hidden;
}

.time-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.time-table th,
.time-table td {
    border: 1px solid var(--color-grid-border);
    padding: 2px 3px;
    line-height: 1.3;
    box-sizing: border-box;
}

.time-header .time-label {
    width: 150px;
    text-align: left;
    background: #f9fafb;
    font-weight: 700;
    color: var(--color-text-main);
}

.hour-cell {
    background: #293245;
    font-weight: 600;
    text-align: center;
    color: var(--color-text-main);
    padding: 4px 2px;
    border-bottom: 1px solid var(--color-grid-border);
}

.row-label,
.row-label-rtl {
    background: #1e2539;
    font-weight: 600;
    padding-left: 4px;
    padding-right: 4px;
    white-space: nowrap;
    color: var(--color-text-main);
}

.row-label {
    text-align: left;
}

.row-label-rtl {
    direction: rtl;
    text-align: right;
}

.time-cell {
    text-align: center;
    vertical-align: middle;
    height: 24px;
    min-width: 32px;
    cursor: pointer;
    background: #293345;
    color: var(--color-text-main);
    transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.time-cell:hover {
    background: #33415c;
    box-shadow: inset 0 0 0 1px var(--color-primary);
}

.time-cell.cell-marked {
    background: #3f4d70;
    box-shadow: inset 0 0 0 2px var(--color-accent);
}

.section-divider .section-title {
    background: #374151;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    padding: 4px 6px;
    text-align: left;
    letter-spacing: 0.12em;
    color: var(--color-text-main);
}

.section-subtitle-row .section-subtitle {
    background: #2c344d;
    font-size: 11px;
    text-align: center;
    letter-spacing: 0.08em;
    padding: 4px 4px;
    color: var(--color-text-muted);
}

.bg-yellow {
    background: #524646;
    color: #fef3c7;
}

.bg-green {
    background: #3a4933;
    color: #d1fae5;
}

.bg-pink {
    background: #4a3a46;
    color: #f9e2e7;
}

.time-cell.file-cell {
    font-size: 16px;
    cursor: default;
    background: transparent;
}

.site-footer {
    background: #0f172a;
    border-top: 1px solid var(--color-grid-border);
    padding: 14px 18px 18px;
    text-align: center;
}

.site-disclaimer {
    margin: 0 0 6px 0;
    font-weight: 700;
    color: #fcd34d;
}

.site-footer-meta {
    margin: 0;
    font-size: 12px;
}

.toxin-banner {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.5);
    border-radius: 10px;
    padding: 10px 12px;
    color: #fcd34d;
    font-weight: 600;
}

.toxin-form {
    margin-top: 14px;
}

.toxin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.toxin-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
}

.toxin-field select,
.toxin-field input {
    background: #111827;
    border: 1px solid var(--color-grid-border);
    border-radius: 10px;
    color: var(--color-text-main);
    padding: 10px 12px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.toxin-field select:focus,
.toxin-field input:focus {
    border-color: var(--color-primary-strong);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.35);
}

.toxin-field input[dir="ltr"] {
    text-align: end;
}

.toxin-submit {
    margin-top: 14px;
    border: 1px solid var(--color-primary-strong);
    background: linear-gradient(90deg, var(--color-primary-soft), var(--color-primary));
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    padding: 12px 22px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.toxin-submit:hover {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.toxin-submit:active {
    transform: scale(0.98);
}

.toxin-result {
    margin-top: 16px;
    border-radius: 12px;
    border: 1px solid var(--color-grid-border);
    border-inline-start-width: 6px;
    background: #202a3d;
    padding: 14px 16px;
    display: grid;
    gap: 8px;
}

.toxin-result[data-band="watch"] {
    border-inline-start-color: #64748b;
}

.toxin-result[data-band="moderate"] {
    border-inline-start-color: var(--color-accent);
}

.toxin-result[data-band="severe"] {
    border-inline-start-color: #fb7185;
}

.toxin-result[data-band="critical"] {
    border-inline-start-color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.toxin-result[data-band="error"] {
    border-inline-start-color: #f87171;
}

.toxin-result p {
    margin: 0;
}

.toxin-band-label {
    font-weight: 700;
    font-size: 16px;
}

.toxin-result[data-band="watch"] .toxin-band-label {
    color: #cbd5e1;
}

.toxin-result[data-band="moderate"] .toxin-band-label {
    color: #fcd34d;
}

.toxin-result[data-band="severe"] .toxin-band-label {
    color: #fda4af;
}

.toxin-result[data-band="critical"] .toxin-band-label {
    color: #fca5a5;
}

.toxin-error {
    color: #fca5a5;
    font-weight: 600;
}

.toxin-source {
    font-size: 12px;
}

.toxin-species {
    font-size: 12px;
}

.toxin-emergency {
    border-top: 1px dashed var(--color-grid-border);
    padding-top: 10px;
    display: grid;
    gap: 10px;
    font-weight: 600;
}

.toxin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.toxin-call,
.toxin-share {
    display: inline-block;
    border-radius: 10px;
    padding: 11px 18px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.toxin-call {
    background: #dc2626;
    color: #ffffff;
    border-color: #f87171;
}

.toxin-call-setup {
    background: transparent;
    color: #fca5a5;
}

.toxin-share {
    background: #25d366;
    color: #073b1c;
    border-color: #128c7e;
}

.toxin-call:hover,
.toxin-share:hover {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.toxin-call:active,
.toxin-share:active {
    transform: scale(0.98);
}

.toxin-disclaimer {
    font-size: 12px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-grid-border);
    padding-top: 8px;
}

.toxin-settings {
    margin-top: 16px;
    border-top: 1px dashed var(--color-grid-border);
    padding-top: 12px;
    max-width: 360px;
}

.toxin-settings-hint {
    margin: 6px 0 0 0;
    font-size: 12px;
}

.calc-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-block: 14px 4px;
}

.calc-pill {
    border: 1px solid var(--color-grid-border);
    background: #111827;
    color: var(--color-text-main);
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.calc-pill:hover {
    background: #2c344d;
}

.calc-pill:active {
    transform: scale(0.97);
}

.calc-pill.active {
    background: linear-gradient(90deg, var(--color-primary-soft), var(--color-primary));
    border-color: var(--color-primary-strong);
    color: #ffffff;
}

.calc-section {
    display: none;
    margin-block-start: 12px;
}

.calc-section.active {
    display: block;
}

.calc-title {
    margin: 0 0 6px 0;
    font-size: 17px;
}

.toxin-onset {
    color: #c4b5fd;
    font-size: 13px;
    font-weight: 600;
}

.calc-recover-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-block: 4px;
}

.calc-recover-table th,
.calc-recover-table td {
    border: 1px solid var(--color-grid-border);
    padding: 6px 8px;
    text-align: start;
    vertical-align: top;
}

.calc-recover-table th {
    background: #293245;
    font-weight: 700;
}

.calc-recover-table tbody tr:nth-child(even) {
    background: #1b2335;
}

@media print {
    html,
    body {
        background: #ffffff;
    }

    .sheet {
        max-width: none;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
        border: none;
        padding: 8mm;
    }

    .patient-header {
        border-radius: 0;
    }

    .time-cell {
        cursor: default;
        box-shadow: none !important;
    }
}
