*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --brand-green: #2ea043;
    --brand-green-dark: #268735;
    --brand-green-light: #ecfdf3;
    --brand-green-header: #e8f5ec;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--surface-muted);
    color: var(--text-primary);
    line-height: 1.45;
    font-size: 1rem;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
    padding: 0.85rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.clinic-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.clinic-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.clinic-name {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}

.user-avatar {
    position: relative;
    flex-shrink: 0;
}

.user-avatar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid var(--border-color);
}

.user-avatar-icon svg {
    width: 22px;
    height: 22px;
}

.user-avatar-status {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--brand-green);
    border: 2px solid var(--surface);
}

.app-toolbar {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.search-form {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.65rem;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 560px;
}

.search-input-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    color: #94a3b8;
    pointer-events: none;
}

.search-icon svg {
    width: 18px;
    height: 18px;
}

.search-form input[type="search"] {
    width: 100%;
    padding: 0.7rem 0.9rem 0.7rem 2.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
}

.search-form input[type="search"]:focus {
    outline: 2px solid var(--brand-green);
    outline-offset: 0;
    border-color: var(--brand-green);
}

.search-form button {
    padding: 0.7rem 1.25rem;
    border: none;
    border-radius: 8px;
    background: var(--brand-green);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-form button:hover {
    background: var(--brand-green-dark);
}

.clear-link {
    display: inline-flex;
    align-items: center;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 1rem;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.clear-link:hover {
    background: var(--surface-muted);
    color: var(--text-primary);
}

.app-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem 1.25rem;
}

.results-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-bottom: 0.75rem;
}

.results-bar.is-loading .results-count-badge {
    color: #94a3b8;
}

.results-count-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.clear-link[hidden],
.empty-message[hidden],
.table-wrap[hidden],
.pagination[hidden],
.results-count[hidden] {
    display: none;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-top: 0.85rem;
}

.pagination-btn {
    padding: 0.55rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--brand-green-light);
    border-color: #b7e0c2;
    color: var(--brand-green-dark);
}

.pagination-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pagination-status {
    color: var(--text-muted);
    font-size: 0.9375rem;
    font-weight: 500;
    min-width: 4.5rem;
    text-align: center;
}

.empty-message {
    margin: 0;
    padding: 1rem 0;
    color: var(--text-muted);
    font-size: 1rem;
}

.table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

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

thead {
    background: var(--brand-green-header);
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--brand-green-header);
    box-shadow: 0 1px 0 #d8ebde;
}

th,
td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9375rem;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    vertical-align: top;
}

th {
    font-weight: 700;
    color: var(--brand-green);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.8125rem;
}

tbody tr:nth-child(even) {
    background: #fcfdfc;
}

tbody tr:hover {
    background: var(--brand-green-light);
}

tbody tr:last-child td {
    border-bottom: none;
}

.col-name {
    width: 24%;
    min-width: 0;
}

.col-number {
    width: 12%;
}

.col-birthday {
    width: 11%;
}

.col-address {
    width: 28%;
}

.col-date {
    width: 13%;
}

.col-yakap {
    width: 12%;
}

.patient-name-cell {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

.patient-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-green-light);
    color: var(--brand-green);
}

.patient-name {
    min-width: 0;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.col-number,
.col-birthday,
.col-date {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.col-address {
    color: var(--text-secondary);
}

.search-highlight {
    background: #fef08a;
    color: var(--text-primary);
    padding: 0 0.1em;
    border-radius: 2px;
    font-weight: 600;
    box-decoration-break: clone;
}

.yakap-badge {
    display: inline-block;
    padding: 0.2em 0.55em;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.yakap-interviewed {
    background: #dcfce7;
    color: #166534;
}

.yakap-needs-interview {
    background: #fee2e2;
    color: #991b1b;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 640px) {
    .app-header {
        padding: 0.75rem 1rem;
    }

    .clinic-logo {
        height: 40px;
    }

    .clinic-name {
        font-size: 1.05rem;
    }

    .app-toolbar,
    .app-main {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .search-form {
        max-width: none;
    }

    .search-input-wrap {
        max-width: none;
    }

    .results-bar {
        justify-content: flex-start;
    }

    th,
    td {
        padding: 0.65rem 0.75rem;
        font-size: 0.875rem;
    }

    .patient-avatar {
        width: 28px;
        height: 28px;
    }
}
