* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --page: #f4f7fb;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --card: #ffffff;
    --blue: #2563eb;
    --red: #dc2626;
    --amber: #b45309;
}

body {
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--page);
    line-height: 1.6;
}

button,
input,
select {
    font: inherit;
}

.header {
    width: 100%;
    padding: 18px 6%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
}

.logo h1 {
    font-size: 28px;
    line-height: 1.1;
    margin-bottom: 4px;
}

.logo p,
.user-info p {
    font-size: 13px;
    opacity: .9;
}

.user-info {
    text-align: right;
}

.user-info h3 {
    font-size: 16px;
}

.nav {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 10px 6%;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.nav a {
    padding: 8px 13px;
    border-radius: 7px;
    text-decoration: none;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
}

.nav a:hover,
.nav a.active {
    color: var(--primary);
    background: #f0fdfa;
}

.container {
    width: min(88%, 1200px);
    margin: 30px auto;
}

.display-container {
    width: min(95%, 1400px);
}

.page-heading {
    margin-bottom: 22px;
}

.page-heading h2 {
    font-size: 26px;
    color: #111827;
}

.page-heading p {
    color: var(--muted);
}

.card {
    margin-bottom: 25px;
    padding: 25px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .06);
}

.card h2 {
    margin-bottom: 20px;
    font-size: 21px;
    color: #111827;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    min-height: 128px;
    padding: 22px;
    background: #fff;
    border-left: 5px solid var(--primary);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .07);
}

.stat-card h3 {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
}

.stat-card p {
    color: var(--primary);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.15;
}

.stat-card small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

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

.form-group label {
    margin-bottom: 7px;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
}

.form-group input,
.form-group select,
.token-lookup input {
    width: 100%;
    padding: 12px 14px;
    color: var(--ink);
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.form-group input:focus,
.form-group select:focus,
.token-lookup input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .1);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 11px 19px;
    color: #fff;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background .2s, transform .2s;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn.secondary {
    color: var(--primary);
    border: 1px solid #99d6d0;
    background: #f0fdfa;
}

.btn.secondary:hover {
    background: #ccfbf1;
}

.btn.next {
    background: var(--blue);
}

.btn.next:hover {
    background: #1d4ed8;
}

.btn.pause {
    background: var(--amber);
}

.btn.pause:hover {
    background: #92400e;
}

.btn.skip {
    background: var(--red);
}

.btn.skip:hover {
    background: #b91c1c;
}

.btn.end {
    background: #7c2d12;
}

.btn.end:hover {
    background: #5a1f0a;
}

.notice {
    display: none;
    margin-top: 22px;
    padding: 17px 19px;
    border: 1px solid #99d6d0;
    border-radius: 10px;
    color: #115e59;
    background: #f0fdfa;
}

.notice.show {
    display: block;
}

.notice strong {
    display: block;
    margin-bottom: 3px;
    font-size: 17px;
}

.patient-display {
    overflow: hidden;
    color: #fff;
    background: #111827;
}

.patient-display h2 {
    color: #fff;
}

.display-screen {
    padding: 35px;
    text-align: center;
    border-radius: 12px;
    background: #1f2937;
}

.display-title {
    margin-bottom: 5px;
    color: #9ca3af;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
}

.display-token {
    margin: 9px 0;
    color: #fff;
    font-size: clamp(56px, 10vw, 95px);
    line-height: 1;
}

.display-name {
    min-height: 35px;
    margin-bottom: 28px;
    font-size: 21px;
}

.display-info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    max-width: 650px;
    margin: auto;
}

.display-info div {
    padding: 17px;
    border-radius: 10px;
    background: #374151;
}

.display-info span {
    display: block;
    margin-bottom: 4px;
    color: #d1d5db;
    font-size: 13px;
}

.display-info strong {
    color: #fff;
    font-size: 24px;
}

.token-lookup {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.token-lookup label {
    width: 100%;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
}

.token-lookup input {
    max-width: 290px;
}

.position-result {
    display: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
    margin-top: 24px;
}

.position-result.show {
    display: grid;
}

.position-item {
    padding: 18px;
    text-align: center;
    border-radius: 9px;
    background: #f0fdfa;
}

.position-item span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.position-item strong {
    color: var(--primary);
    font-size: 24px;
}

.current-section {
    border-top: 4px solid var(--primary);
}

.current-patient {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.current-patient div {
    padding: 20px;
    text-align: center;
    border-radius: 10px;
    background: #f0fdfa;
}

.current-patient span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
}

.current-patient strong {
    color: var(--primary);
    font-size: 23px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
}

.table-container {
    overflow-x: auto;
}

.display-table table {
    font-size: 13px;
}

.display-table th,
.display-table td {
    padding: 10px;
}

table {
    width: 100%;
    min-width: 650px;
    border-collapse: collapse;
}

thead {
    background: #f0fdfa;
}

th,
td {
    padding: 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

th {
    color: #374151;
    font-size: 13px;
}

tbody tr:hover {
    background: #f9fafb;
}

.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.status.waiting {
    color: #92400e;
    background: #fef3c7;
}

.status.consulting {
    color: #1e40af;
    background: #dbeafe;
}

.status.completed {
    color: #166534;
    background: #dcfce7;
}

.empty-row {
    padding: 24px;
    text-align: center;
    color: var(--muted);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #111827;
    font-size: 22px;
}

.modal-content p {
    margin-bottom: 25px;
    color: var(--muted);
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-buttons .btn {
    flex: 1;
    min-width: 150px;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #0f766e 0%, #115e59 42%, #1f2937 100%);
}

.login-card {
    width: min(100%, 460px);
    padding: 38px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.login-brand {
    margin-bottom: 28px;
    text-align: center;
}

.login-brand h1 {
    color: var(--primary);
    font-size: 30px;
}

.login-brand p {
    color: var(--muted);
    font-size: 14px;
}

.login-card .btn {
    width: 100%;
    margin-top: 24px;
}

.login-help {
    margin-top: 20px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

.footer {
    margin-top: 40px;
    padding: 23px;
    color: #9ca3af;
    text-align: center;
    background: #111827;
}

.footer p {
    margin: 2px;
    font-size: 13px;
}

@media (max-width: 900px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .current-patient {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .header {
        align-items: flex-start;
        flex-direction: column;
        padding: 17px 5%;
    }

    .user-info {
        text-align: left;
    }

    .nav {
        justify-content: flex-start;
        overflow-x: auto;
        padding: 9px 4%;
    }

    .nav a {
        white-space: nowrap;
    }

    .container {
        width: 94%;
        margin: 21px auto;
    }

    .card,
    .login-card {
        padding: 21px;
    }

    .stats,
    .form-grid,
    .current-patient,
    .display-info,
    .position-result {
        grid-template-columns: 1fr;
    }

    .form-group.full-width {
        grid-column: auto;
    }

    .action-buttons,
    .form-actions {
        flex-direction: column;
    }

    .action-buttons .btn,
    .form-actions .btn,
    .token-lookup .btn {
        width: 100%;
    }

    .token-lookup {
        align-items: stretch;
        flex-direction: column;
    }

    .token-lookup input {
        max-width: none;
    }

    .modal-content {
        width: 95%;
    }
}
