/* =========================================================
   KRDS(대한민국 정부 디자인시스템, https://www.krds.go.kr) 토큰 기반 스타일
   색상/타이포/간격 값은 KRDS 공식 디자인 토큰(krds-uiux 저장소)을 그대로 사용.
   클래스 구조는 기존과 동일하게 유지(기능 변경 없음).
   ========================================================= */

@font-face {
    font-family: 'Pretendard';
    font-weight: 400;
    font-display: swap;
    src: url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/woff2/Pretendard-Regular.woff2') format('woff2');
}
@font-face {
    font-family: 'Pretendard';
    font-weight: 500;
    font-display: swap;
    src: url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/woff2/Pretendard-Medium.woff2') format('woff2');
}
@font-face {
    font-family: 'Pretendard';
    font-weight: 700;
    font-display: swap;
    src: url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/woff2/Pretendard-Bold.woff2') format('woff2');
}

:root {
    /* KRDS primitive.color.light.primary */
    --primary: #256ef4;
    --primary-dark: #0b50d0;
    --primary-darker: #083891;
    --primary-soft: #ecf2fe;
    --primary-soft-border: #d8e5fd;

    /* KRDS primitive.color.light.gray */
    --gray-0: #ffffff;
    --gray-5: #f4f5f6;
    --gray-10: #e6e8ea;
    --gray-20: #cdd1d5;
    --gray-30: #b1b8be;
    --gray-40: #8a949e;
    --gray-50: #6d7882;
    --gray-60: #58616a;
    --gray-70: #464c53;
    --gray-90: #1e2124;

    --bg: var(--gray-5);
    --surface: var(--gray-0);
    --border: var(--gray-20);
    --border-strong: var(--gray-30);
    --text: var(--gray-90);
    --text-muted: var(--gray-70);
    --text-faint: var(--gray-50);

    /* KRDS semantic danger/success/warning/information (50=진한색, 5/10=배경) */
    --danger: #de3412;
    --danger-dark: #bd2c0f;
    --danger-bg: #fdefec;
    --success: #228738;
    --success-dark: #267337;
    --success-bg: #eaf6ec;
    --warn: #9e6a00;
    --warn-dark: #8a5c00;
    --warn-bg: #fff3db;
    --info: #0b78cb;
    --info-bg: #e7f4fe;

    /* KRDS semantic.radius (primitive.number 기준, 10px root 환산) */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 999px;

    --shadow: 0 1px 4px rgba(30, 33, 36, 0.06);
    --shadow-md: 0 4px 14px rgba(30, 33, 36, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Pretendard', -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 16px 40px;
}

/* ---------- Login / Entry ---------- */

.login-container {
    padding-top: 13vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeInUp 0.4s ease;
}

.app-logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.app-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}

.app-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 28px;
}

.login-container .form {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    box-shadow: var(--shadow);
}

.entry-choices {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.entry-choice {
    display: block;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.entry-choice:active {
    background: var(--gray-5);
}

.entry-choice-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.entry-choice-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.entry-choice.is-primary {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.entry-choice.is-primary .entry-choice-title {
    color: var(--primary-dark);
}

/* ---------- Login footer links ---------- */

.login-links-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
    font-size: 13px;
}

.login-links-row a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
}

.login-links-row a:active,
.login-links-row a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.login-links-divider {
    width: 1px;
    height: 12px;
    background: var(--border);
}

.login-section-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-faint);
    font-size: 12px;
    margin: 22px 0 14px;
}

.login-section-divider::before,
.login-section-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-section-divider span {
    padding: 0 10px;
    white-space: nowrap;
}

.login-signup-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.login-signup-links .btn {
    width: 100%;
    margin-top: 0;
}

/* ---------- Layout / App bar ---------- */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 4px 0 18px;
}

.staff-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.staff-name {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}

.center-name {
    font-size: 12.5px;
    color: var(--text-muted);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 17px;
    font-weight: 700;
    margin: 4px 0 14px;
    padding-left: 10px;
    border-left: 4px solid var(--primary);
}

.badge-count {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-radius: var(--radius-full);
    padding: 3px 10px;
}

.status-badge {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: var(--radius-full);
    padding: 3px 10px;
}

.status-pending { color: var(--warn-dark); background: var(--warn-bg); }
.status-approved,
.status-active { color: var(--success-dark); background: var(--success-bg); }
.status-rejected,
.status-resigned,
.status-ended { color: var(--danger-dark); background: var(--danger-bg); }

/* ---------- Tab nav (standalone admin) ---------- */

.tab-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    margin-bottom: 18px;
    padding-bottom: 2px;
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* IE/Edge */
}

.tab-nav::-webkit-scrollbar {
    display: none;              /* Chrome/Safari/Android WebView */
}

.tab-nav a {
    flex-shrink: 0;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 8px 14px;
}

.tab-nav a.is-active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

/* ---------- Month filter ---------- */

.month-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 6px 8px;
    margin-bottom: 18px;
}

.month-filter input[type="month"] {
    flex: 1;
    padding: 6px 4px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--text);
}

.month-nav {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--primary);
    transition: background 0.15s ease;
}

.month-nav:active {
    background: var(--primary-soft);
}

/* ---------- Buttons / links ---------- */

.btn {
    display: inline-block;
    text-align: center;
    padding: 13px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 15.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    margin-top: 20px;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:active {
    background: var(--primary-darker);
    opacity: 0.95;
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
    width: 100%;
    margin-top: 10px;
}

.btn-secondary:hover {
    background: var(--gray-5);
}

.btn-small {
    padding: 8px 12px;
    font-size: 13px;
    width: auto;
    margin-top: 0;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-dark);
    padding: 6px 4px;
    font-weight: 600;
    font-size: 14px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-row {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.action-row .btn {
    margin-top: 0;
    flex: 1;
}

/* ---------- Alerts ---------- */

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid var(--danger);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-dark);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-dark);
    border-left-color: var(--success);
}

.alert-info {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-left-color: var(--primary);
}

/* ---------- Cards / list ---------- */

.card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    display: block;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 14px 30px 14px 16px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s ease, background 0.15s ease;
    animation: fadeInUp 0.35s ease;
}

.card:active {
    background: var(--gray-5);
}

@media (hover: hover) {
    .card:hover {
        border-color: var(--primary);
        background: var(--gray-5);
    }
}

.card::after {
    content: "\203A";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: 20px;
    font-weight: 700;
}

.card-date {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.card-hospital {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 16.5px;
    font-weight: 700;
    margin: 4px 0 6px;
}

.icon-pin {
    color: var(--primary);
    flex-shrink: 0;
}

.card-patient {
    display: inline-block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-radius: var(--radius-full);
    padding: 2px 10px;
    margin-bottom: 6px;
}

.card-sub {
    font-size: 12.5px;
    color: var(--text-muted);
}

.empty-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 44px 20px;
}

.empty-message svg {
    color: var(--text-faint);
}

.empty-message p {
    margin: 0;
}

/* ---------- Info box (detail) ---------- */

.info-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
    animation: fadeInUp 0.35s ease;
}

.info-list {
    display: grid;
    grid-template-columns: 100px 1fr;
    row-gap: 0;
    margin: 0;
}

.info-list dt,
.info-list dd {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.info-list dt:last-of-type,
.info-list dd:last-of-type {
    border-bottom: none;
}

.info-list dt {
    color: var(--text-muted);
    font-weight: 600;
}

.info-list dd {
    margin: 0;
    font-weight: 500;
}

/* ---------- Forms ---------- */

.form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-subtitle {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 4px 0 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.form-subtitle:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 10px;
}

.form input,
.form select,
.form textarea {
    padding: 11px 12px;
    font-size: 15px;
    border: 1px solid var(--gray-60);
    border-radius: var(--radius-sm);
    width: 100%;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-hint {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 2px;
}

.address-search-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.address-search-row input {
    flex: 1;
    width: auto;
    min-width: 0;
}

.address-search-row .btn {
    flex-shrink: 0;
    width: auto;
    margin-top: 0;
    white-space: nowrap;
}

.checkbox-group,
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip-checkbox,
.chip-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    padding: 9px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip-checkbox input,
.chip-radio input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.chip-checkbox::before {
    content: "";
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.chip-checkbox:has(input:checked),
.chip-radio:has(input:checked) {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.chip-checkbox:has(input:checked)::before {
    background: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12l5 5 11-11'/%3E%3C/svg%3E");
    background-size: 11px 11px;
    background-repeat: no-repeat;
    background-position: center;
}

/* ---------- Signature pad ---------- */

.signature-pad {
    display: block;
    width: 100%;
    height: 150px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    touch-action: none;
}

.signature-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.signature-hint {
    font-size: 12px;
    color: var(--text-faint);
}

.signature-preview {
    max-width: 220px;
    max-height: 90px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    margin-top: 8px;
    display: block;
}

/* ---------- Receipt attachments ---------- */

.receipt-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.receipt-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.receipt-thumbs a {
    display: block;
}

.receipt-thumbs img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.receipt-thumbs .file-icon {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

/* ---------- Table (list views, backup) ---------- */

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data-table th,
table.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table th {
    background: var(--gray-5);
    color: var(--text);
    font-weight: 700;
}

table.data-table tr:last-child td {
    border-bottom: none;
}

/* ---------- Print report (별지 서식) ---------- */

.report-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
}

.report-title {
    text-align: center;
    font-size: 18px;
    font-weight: 800;
    margin: 0 0 4px;
}

.report-subtitle {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 16px;
}

table.form-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    margin-bottom: 14px;
}

table.form-table th,
table.form-table td {
    border: 1px solid var(--text);
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

table.form-table th {
    background: var(--gray-5);
    font-weight: 700;
    width: 90px;
}

table.form-table td.center {
    text-align: center;
}

.print-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.print-actions .btn {
    margin-top: 0;
    flex: 1;
}

@media print {
    body {
        background: #fff;
    }
    .page-header,
    .print-actions,
    .tab-nav,
    .btn-link {
        display: none !important;
    }
    .container {
        max-width: 100%;
        padding: 0;
    }
    .report-box {
        box-shadow: none;
        border-radius: 0;
    }
}
