/* start section style_css */

:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #061528;
    --muted: #64748b;
    --line: #d8e4f0;
    --line-soft: #e7eef6;
    --header-bg: #f4f8fb;
    --primary: #005bc8;
    --primary-dark: #004aa3;
    --secondary: #eef3f8;
    --secondary-text: #1e293b;
    --danger-bg: #fee2e2;
    --danger-border: #fecaca;
    --danger-text: #7f1d1d;
    --info-bg: #e0f2fe;
    --info-border: #7dd3fc;
    --info-text: #075985;
    --shadow: 0 10px 25px rgba(15, 23, 42, 0.04);
    --calendar-weekend-column: 8.5%;
    --calendar-workday-column: calc((100% - (2 * var(--calendar-weekend-column))) / 5);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.login-page {
    width: 100%;
    max-width: 420px;
}

.login-card,
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.login-card {
    padding: 26px;
}

.login-logo {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 18px;
}

h1 {
    margin: 0 0 14px;
    font-size: 22px;
    font-weight: 800;
}

h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

p {
    line-height: 1.45;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.message {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 700;
}

.message-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}

.message-info {
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    color: var(--info-text);
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-field {
    display: grid;
    gap: 6px;
}

label {
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: Arial, sans-serif;
    font-size: 15px;
    background: #ffffff;
}

input[type="checkbox"] {
    width: auto;
    min-height: 0;
    padding: 0;
    border-radius: 4px;
    accent-color: var(--primary);
}

textarea {
    min-height: 90px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(0, 91, 200, 0.18);
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-text);
    border-color: var(--line);
}

.btn-small {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 14px;
}

.btn-full {
    width: 100%;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 14px 22px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.app-title {
    font-size: 20px;
    font-weight: 800;
}

.app-subtitle {
    color: var(--muted);
    font-size: 14px;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-main {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.card {
    padding: 18px;
    margin-bottom: 18px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: end;
}

.filter-checkbox-field {
    align-self: end;
}

.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    min-height: 40px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
}

.checkbox-option input {
    margin-top: 3px;
    flex: 0 0 auto;
}

.checkbox-copy {
    display: grid;
    gap: 2px;
}

.checkbox-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}

.checkbox-hint {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    line-height: 1.2;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.section-header h1 {
    margin: 0;
}

.period-label {
    font-size: 18px;
    font-weight: 800;
}

.print-only {
    display: none;
}

.print-meta {
    margin-top: 4px;
    font-size: 11px;
    color: #000000;
}

/* start section calendar_layout_css */

.calendar-card,
.table-card {
    overflow: hidden;
}

.calendar-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
}

.calendar-table {
    width: 100%;
    min-width: 980px;
    table-layout: fixed;
    border-collapse: collapse;
    background: #ffffff;
}

.calendar-col-workday {
    width: var(--calendar-workday-column);
}

.calendar-col-weekend {
    width: var(--calendar-weekend-column);
}

.calendar-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: 800;
    background: #ffffff;
    border: 1px solid var(--line-soft);
}

.calendar-table td {
    height: 126px;
    vertical-align: top;
    border: 1px solid var(--line-soft);
    padding: 0;
    background: #ffffff;
}

.calendar-table th:nth-child(6),
.calendar-table th:nth-child(7) {
    padding-left: 4px;
    padding-right: 4px;
}

.calendar-table td:nth-child(6) .calendar-cell-date,
.calendar-table td:nth-child(7) .calendar-cell-date {
    padding-left: 4px;
    padding-right: 4px;
    text-align: center;
    font-size: 12px;
}

.calendar-cell-date {
    padding: 6px 8px;
    min-height: 27px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--line-soft);
    font-size: 14px;
    font-weight: 800;
}

.calendar-order {
    padding: 7px 8px 8px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
    line-height: 1.22;
}

.calendar-order:last-child {
    border-bottom: none;
}

.calendar-order-time {
    font-weight: 800;
    color: #111827;
    margin-bottom: 3px;
}

.calendar-order-patient,
.calendar-order-worktype {
    display: block;
    font-weight: 800;
    margin-bottom: 3px;
}

.calendar-order-worktype {
    color: #111827;
}

.calendar-order-line {
    color: #111827;
}

.calendar-status-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

.calendar-status-text {
    font-weight: 600;
}

.calendar-status-marker {
    display: none;
    width: 28px;
    height: 8px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.calendar-order.status-red .calendar-status-marker,
.calendar-order.status-yellow .calendar-status-marker,
.calendar-order.status-green .calendar-status-marker,
.calendar-order.status-gray .calendar-status-marker {
    display: inline-block;
}

.calendar-order.status-red .calendar-status-marker {
    background: #ef4444;
}

.calendar-order.status-yellow .calendar-status-marker {
    background: #facc15;
}

.calendar-order.status-green .calendar-status-marker {
    background: #22c55e;
}

.calendar-order.status-gray .calendar-status-marker {
    background: #94a3b8;
}

.calendar-order.status-gray {
    color: #7c8797;
}

.calendar-order.status-gray .calendar-order-time,
.calendar-order.status-gray .calendar-order-patient,
.calendar-order.status-gray .calendar-order-worktype,
.calendar-order.status-gray .calendar-order-line,
.calendar-order.status-gray .calendar-status-text {
    color: #7c8797;
}

.calendar-order.status-gray a {
    color: #7c8797;
}

.calendar-order-actions {
    margin-top: 4px;
    font-size: 12px;
}

.calendar-order-actions a {
    font-weight: 700;
}

/* end section calendar_layout_css */

/* start section table_layout_css */

.table-scroll {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    background: #ffffff;
}

th,
td {
    border-bottom: 1px solid var(--line-soft);
    padding: 11px 14px;
    text-align: left;
    vertical-align: top;
    line-height: 1.35;
}

th {
    background: var(--header-bg);
    font-weight: 800;
    color: #111827;
    border-bottom: 1px solid var(--line);
}

tr:last-child td {
    border-bottom: none;
}

.orders-table tr.table-day-gray td {
    background: #f8fafc;
}

.orders-table tr.table-day-white td {
    background: #ffffff;
}

.orders-table tr.table-day-separator td {
    height: 0;
    padding: 0 !important;
    line-height: 0;
    font-size: 0;
    background: #ffffff !important;
    border-top: 2px solid var(--line) !important;
    border-bottom: none !important;
}

.table-status-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: normal;
}

.table-status-text {
    font-weight: 600;
}

.table-status-marker {
    display: none;
    width: 22px;
    height: 8px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.table-status-line.status-red .table-status-marker,
.table-status-line.status-yellow .table-status-marker,
.table-status-line.status-green .table-status-marker,
.table-status-line.status-gray .table-status-marker {
    display: inline-block;
}

.table-status-line.status-red .table-status-marker {
    background: #ef4444;
}

.table-status-line.status-yellow .table-status-marker {
    background: #facc15;
}

.table-status-line.status-green .table-status-marker {
    background: #22c55e;
}

.table-status-line.status-gray .table-status-marker {
    background: #94a3b8;
}

.orders-table tr.table-row-muted td,
.orders-table tr.table-row-muted a,
.orders-table tr.table-row-muted .table-status-text {
    color: #7c8797;
}

.action-cell {
    white-space: nowrap;
}

.action-cell a {
    display: block;
    white-space: nowrap;
    line-height: 1.45;
}

.no-print-link {
    color: var(--primary);
}

/* end section table_layout_css */

.order-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
    align-items: start;
}

.form-field-wide {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-start;
}

.storage-box {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    background: #ffffff;
}

.storage-box h2 {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 800;
}

.storage-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr 1fr 1fr;
    gap: 12px;
    align-items: end;
}

#storage_code {
    font-weight: 700;
    background: #f8fafc;
}

/* start section desktop_table_layout_css */

@media (min-width: 1101px) {
    .table-scroll {
        overflow-x: visible;
    }

    .orders-table {
        table-layout: fixed;
        width: 100%;
        font-size: 13px;
    }

    .orders-table th,
    .orders-table td {
        min-width: 0 !important;
        padding: 9px 8px;
        word-break: normal;
        overflow-wrap: normal;
        hyphens: none;
    }

    .orders-table th:nth-child(1),
    .orders-table td:nth-child(1) {
        width: 14%;
    }

    .orders-table th:nth-child(2),
    .orders-table td:nth-child(2) {
        width: 9%;
    }

    .orders-table th:nth-child(3),
    .orders-table td:nth-child(3) {
        width: 12%;
    }

    .orders-table th:nth-child(4),
    .orders-table td:nth-child(4) {
        width: 12%;
    }

    .orders-table th:nth-child(5),
    .orders-table td:nth-child(5) {
        width: 6%;
    }

    .orders-table th:nth-child(6),
    .orders-table td:nth-child(6) {
        width: 10%;
    }

    .orders-table th:nth-child(7),
    .orders-table td:nth-child(7) {
        width: 10%;
    }

    .orders-table th:nth-child(8),
    .orders-table td:nth-child(8) {
        width: 8%;
    }

    .orders-table th:nth-child(9),
    .orders-table td:nth-child(9) {
        width: 10%;
    }

    .orders-table th:nth-child(10),
    .orders-table td:nth-child(10) {
        width: 9%;
        min-width: 92px !important;
        white-space: nowrap;
        overflow-wrap: normal;
        word-break: normal;
    }

    .orders-table td:nth-child(1),
    .orders-table td:nth-child(3),
    .orders-table td:nth-child(6),
    .orders-table td:nth-child(7),
    .orders-table td:nth-child(9) {
        white-space: normal;
        overflow-wrap: break-word;
    }

    .orders-table td:nth-child(2),
    .orders-table td:nth-child(4),
    .orders-table td:nth-child(5),
    .orders-table td:nth-child(8) {
        white-space: normal;
        overflow-wrap: normal;
    }

    .action-cell {
        white-space: nowrap;
        font-size: 12px;
        line-height: 1.45;
        text-align: left;
    }

    .action-cell a {
        display: block;
        white-space: nowrap;
        line-height: 1.45;
        word-break: normal;
        overflow-wrap: normal;
    }

    .table-status-marker {
        width: 22px;
        height: 7px;
    }
}

/* end section desktop_table_layout_css */

@media (max-width: 1100px) {
    .storage-grid {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }
}

@media (max-width: 900px) {
    .filter-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }

    .order-form-grid {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 600px) {
    .app-header {
        position: static;
        flex-direction: column;
        align-items: flex-start;
        padding: 14px;
    }

    .user-box {
        width: 100%;
        justify-content: space-between;
    }

    .app-main {
        padding: 14px;
    }

    .card {
        padding: 14px;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .order-form-grid {
        grid-template-columns: 1fr;
    }

    .storage-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    table {
        font-size: 13px;
    }

    th,
    td {
        padding: 8px;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    body {
        background: #ffffff;
        color: #000000;
        font-size: 9pt;
    }

    .no-print,
    .app-header,
    .toolbar,
    .card.no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    body.print-calendar .table-print-section {
        display: none !important;
    }

    body.print-table .calendar-print-section {
        display: none !important;
    }

    body.print-calendar .calendar-print-section,
    body.print-table .table-print-section {
        display: block !important;
    }

    .app-main {
        max-width: none;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .card {
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 0;
        margin: 0;
    }

    .section-header {
        display: block;
        margin-bottom: 6px;
    }

    .section-header h1 {
        font-size: 14pt;
        margin: 0 0 3px;
    }

    .period-label {
        font-size: 12pt;
    }

    .print-meta {
        font-size: 8.5pt;
        margin-bottom: 5px;
    }

    .calendar-table-wrap,
    .table-scroll {
        border: 1px solid #000000;
        border-radius: 0;
        overflow: visible;
    }

    .calendar-table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
        border-collapse: collapse;
    }

    .calendar-table th {
        padding: 4px;
        border: 1px solid #000000;
        font-size: 8.5pt;
        background: #ffffff !important;
    }

    .calendar-table td {
        height: 72px;
        border: 1px solid #000000;
        padding: 0;
        break-inside: avoid;
    }

    .calendar-table td:nth-child(6) .calendar-cell-date,
    .calendar-table td:nth-child(7) .calendar-cell-date {
        font-size: 7pt;
    }

    .calendar-cell-date {
        padding: 3px 4px;
        min-height: 0;
        background: #f2f2f2 !important;
        border-bottom: 1px solid #000000;
        font-size: 7.5pt;
    }

    .calendar-order {
        padding: 3px 4px;
        font-size: 7.1pt;
        line-height: 1.14;
        border-bottom: 1px solid #cccccc;
    }

    .calendar-order-time,
    .calendar-order-patient,
    .calendar-order-worktype {
        font-weight: 800;
    }

    .calendar-status-marker,
    .table-status-marker {
        width: 18px;
        height: 6px;
    }

    .calendar-order-actions {
        display: none !important;
    }

    .no-print-link {
        color: #000000;
        text-decoration: none;
    }

    table {
        width: 100%;
        font-size: 7.5pt;
        border-collapse: collapse;
    }

    th,
    td {
        border: 1px solid #000000;
        padding: 3px 4px;
        line-height: 1.18;
        word-break: normal;
        overflow-wrap: normal;
    }

    .orders-table tr.table-day-separator td {
        height: 0 !important;
        padding: 0 !important;
        line-height: 0 !important;
        font-size: 0 !important;
        background: #ffffff !important;
        border-top: 4px solid #000000 !important;
        border-bottom: none !important;
    }

    th {
        background: #eeeeee !important;
    }

    a {
        color: #000000;
        text-decoration: none;
    }

    .action-cell,
    .action-cell a {
        white-space: nowrap;
    }
}

/* end section style_css */