* {
    box-sizing: border-box;
}


/* =========================================================
   Font
   ========================================================= */

@font-face {
  font-family: "GureumGothic";
  src: url("/fonts/GureumGothic_3.otf") format('opentype');
  font-weight: 300;
  font-style: normal;
}

@font-face {
  font-family: "GureumGothic";
  src: url("/fonts/GureumGothic_4.otf") format('opentype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "GureumGothic";
  src: url("/fonts/GureumGothic_5.otf") format('opentype');
  font-weight: 500;
  font-style: normal;
}

@font-face {
  font-family: "Jeongum";
  src: url("/fonts/Jeongum.otf") format('opentype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
    font-family: "Soomyeongjo";
    src: url("/fonts/Soomyeongjo_3.otf") format("opentype");
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: "Soomyeongjo";
    src: url("/fonts/Soomyeongjo_4.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: "Soomyeongjo";
    src: url("/fonts/Soomyeongjo_5.otf") format("opentype");
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: "LINESeedSansKR";
    src: url("/fonts/LINESeedSansKR_3.otf") format("opentype");
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: "LINESeedSansKR";
    src: url("/fonts/LINESeedSansKR_4.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: "LINESeedSansKR";
    src: url("/fonts/LINESeedSansKR_5.otf") format("opentype");
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_1.otf") format("opentype");
    font-weight: 100;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_2.otf") format("opentype");
    font-weight: 200;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_3.otf") format("opentype");
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_4.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_5.otf") format("opentype");
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_6.otf") format("opentype");
    font-weight: 600;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_7.otf") format("opentype");
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_8.otf") format("opentype");
    font-weight: 800;
    font-style: normal;
}

@font-face {
    font-family: "AppleSDGothicNEO";
    src: url("/fonts/AppleSDGothicNEO_9.otf") format("opentype");
    font-weight: 900;
    font-style: normal;
}

/* =========================================================
   Base
   ========================================================= */

html,
body {
    margin: 0;
    min-height: 100%;

    font-family: "LINESeedSansKR", sans-serif;
    font-weight: 400;

    background: var(--works-page);
    color: var(--works-text);
}

a {
    color: inherit;
    text-decoration: none;
}


/* =========================================================
   App Layout
   ========================================================= */

.app-shell {
    min-height: 100vh;
    display: flex;
}


/* =========================================================
   Sidebar
   ========================================================= */

.sidebar {
    width: 230px;
    flex: 0 0 230px;
    height: 100vh;
    overflow-y: auto;

    background: var(--works-surface);
    border-right: 1px solid var(--works-line);

    padding: 28px 16px;
}

.brand {
    padding: 0 14px 8px;

    font-family: "LINESeedSansKR", sans-serif;
    font-size: 24px;
    font-weight: 500;
    line-height: normal;
    letter-spacing: 0;
    color: var(--brand-color, var(--works-text));
}

.sidebar nav {
    display: grid;
    gap: 5px;
}

.sidebar nav a {
    padding: 12px 14px;

    border-radius: 10px;

    color: var(--works-muted);
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: var(--works-hover);
    color: var(--works-text);
}

@media (max-width: 700px) {
    .sidebar {
        height: auto;
        overflow-y: visible;
    }
}


/* =========================================================
   Main
   ========================================================= */

.main {
    min-width: 0;
    flex: 1;
}


.user-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.user-area a {
    color: var(--works-muted);
}

.user-name {
    font-size: 66.6667%;
    font-weight: 100;
    line-height: 1;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 20px 0;
}


/* =========================================================
   Content
   ========================================================= */

.content {
    padding: 30px;
}

/* Patient and issuance-history pages keep their shell static and scroll only the table. */
body.table-list-page { height: 100vh; min-height: 0; overflow: hidden; }
body.table-list-page .app-shell { height: 100vh; min-height: 0; overflow: hidden; }
body.table-list-page .sidebar { height: 100vh; overflow-y: auto; }
body.table-list-page .main { display: flex; flex-direction: column; height: 100vh; min-height: 0; overflow: hidden; }
body.table-list-page .content { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; overflow: hidden; }
body.table-list-page .page-header { flex: 0 0 68px; }
body.table-list-page .table-list-scroll { flex: 1 1 auto; min-height: 0; overflow-x: auto; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
body.table-list-page .table-list-scroll::-webkit-scrollbar { display: none; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 22px;
}

.page-title {
    margin: 0 0 6px;
    font-family: "LINESeedSansKR", sans-serif;
    font-size: 25px;
    font-weight: 500;
    line-height: normal;
    color: var(--page-title-color, var(--works-text));
}

.page-description {
    margin: 0;
    font-family: "LINESeedSansKR", sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: normal;
    color: var(--page-description-color, var(--works-muted));
}

/* Document page chrome only. Standalone preview/PDF templates do not use this body class. */
body.document-ui-page .page-title { font-size: calc(25px - 1pt); }
body.document-ui-page .page-description { font-size: calc(16px - 1pt); }
body.document-ui-page .certificate-toolbar,
body.document-ui-page .referral-toolbar,
body.document-ui-page .holiday-input-card,
body.document-ui-page .referral-new-sections,
body.document-ui-page .issue-table,
body.document-ui-page .works-toast,
body.document-ui-page .works-confirm-panel { font-size: calc(16px - 1pt); }
body.document-ui-page .works-toast-close { font-size: calc(22px - 1pt); }
body.document-ui-page .works-toast-details { font-size: calc(12px - 1pt); }
body.document-ui-page .works-confirm-panel h2 { font-size: calc(18px - 1pt); }
body.document-ui-page .works-confirm-detail { font-size: calc(13px - 1pt); }

/* =========================================================
   Card
   ========================================================= */

.card {
    background: var(--works-surface);
    border: 1px solid var(--works-line);
    border-radius: 14px;
}

.form-card {
    padding: 28px;
}


/* =========================================================
   Form
   ========================================================= */

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

.form-grid .wide {
    grid-column: 1 / -1;
}

.form-grid label {
    display: grid;
    gap: 8px;

    color: var(--works-muted);
}

input,
select {
    width: 100%;

    padding: 11px 12px;

    border: 1px solid var(--works-line);
    border-radius: 9px;

    background: var(--works-control);
    color: var(--works-text);

    font: inherit;
}

.form-actions {
    display: flex;
    gap: 10px;

    margin-top: 24px;
}


/* =========================================================
   Buttons
   ========================================================= */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 40px;
    padding: 0 16px;

    border: 1px solid var(--works-line);
    border-radius: 9px;

    background: var(--works-elevated);
    color: var(--works-text);

    font: inherit;

    cursor: pointer;
}

.button.primary {
    border-color: var(--works-primary);

    background: var(--works-primary);
    color: var(--works-primary-text);
}

.button-loading-spinner {
    width: 13px;
    height: 13px;
    flex: 0 0 13px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: works-button-spin 0.7s linear infinite;
}

@keyframes works-button-spin { to { transform: rotate(360deg); } }


/* =========================================================
   Table
   ========================================================= */

.table-card {
    overflow: hidden;
}

table {
    width: 100%;

    border-collapse: collapse;
}

th,
td {
    padding: 15px 18px;

    border-bottom: 1px solid var(--works-line);

    text-align: left;
}

th {
    font-weight: 500;
    color: var(--works-subtle);

    background: var(--works-elevated);
}

.actions {
    display: flex;
    gap: 10px;
}


/* =========================================================
   Status / Empty
   ========================================================= */

.status {
    display: inline-block;

    padding: 4px 9px;

    border-radius: 999px;

    background: var(--works-selected);
    color: var(--works-info);

    font-size: 13px;
}

.empty {
    padding: 40px;

    text-align: center;

    color: var(--works-muted);
}


/* =========================================================
   Certificate
   ========================================================= */

.certificate-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    margin-bottom: 20px;
}

.employee-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.employee-picker select {
    width: 180px;
}

/* =========================================================
   Certificate
   ========================================================= */

.certificate-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    margin-bottom: 20px;
}

.employee-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.employee-picker select {
    width: 180px;
}


/* =========================================================
   Certificate Preview
   ========================================================= */

.certificate-preview {
    width: 100%;
    height: calc(100vh - 180px);

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: var(--works-preview-surface);
    border-radius: 14px;

    overflow: hidden;
}

.certificate-preview,
.referral-preview,
.holiday-preview {
    border: 1px solid var(--works-line);
}

html.dark-mode .certificate-preview,
html.dark-mode .referral-preview,
html.dark-mode .holiday-preview {
    border-color: var(--dark-border);
}


/* 실제 A4를 감싸는 영역 */
.certificate-scale {
    width: 210mm;
    height: 297mm;

    flex: 0 0 auto;

    transform-origin: center center;
}
/* Shared controls and dark mode */
.theme-toggle,
.settings-button {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--works-line);
    border-radius: 6px;
    background: var(--works-elevated);
    color: var(--works-text);
    line-height: 1;
    cursor: pointer;
}
.theme-toggle svg,
.settings-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.theme-toggle .sun-icon { display: none; }
.theme-toggle:hover,
.settings-button:hover { background: var(--works-hover); }
.settings-button:disabled { cursor: not-allowed; opacity: .65; }
html.dark-mode .theme-toggle .sun-icon { display: block; }
html.dark-mode .theme-toggle .moon-icon { display: none; }
html.dark-mode .theme-toggle:hover,
html.dark-mode .settings-button:hover { background: var(--dark-hover); }
.sidebar .brand { text-align: center; padding-left: 0; padding-right: 0; }
.sidebar nav a { text-align: center; }
html.dark-mode body,
html.dark-mode .main,
html.dark-mode .content { background: var(--dark-page-bg); color: var(--dark-text); }
html.dark-mode {
    --brand-color: var(--works-text);
    --page-title-color: var(--works-text);
    --page-description-color: var(--works-muted);
    --dark-page-bg: var(--works-page);
    --dark-surface: var(--works-surface);
    --dark-control: var(--works-control);
    --dark-hover: var(--works-hover);
    --dark-border: var(--works-line);
    --dark-text: var(--works-text);
    --dark-muted: var(--works-muted);
    --dark-preview: var(--works-preview-surface);
    --dark-accent: var(--works-primary);
}
html.dark-mode .sidebar,
html.dark-mode .card,
html.dark-mode .form-card { background: var(--dark-surface); border-color: var(--dark-border); }
html.dark-mode .sidebar nav a { color: var(--dark-muted); }
html.dark-mode .sidebar nav a:hover,
html.dark-mode .sidebar nav a.active,
html.dark-mode th { background: var(--dark-hover); color: var(--dark-text); }
html.dark-mode input,
html.dark-mode select,
html.dark-mode .button,
html.dark-mode .theme-toggle,
html.dark-mode .settings-button { background: var(--dark-control); border-color: var(--dark-border); color: var(--dark-text); }
html.dark-mode .button.primary { background: var(--works-primary); border-color: var(--works-primary); color: var(--works-primary-text); }
html.dark-mode th,
html.dark-mode td { border-color: var(--dark-border); }
html.dark-mode .form-grid label { color: var(--dark-muted); }
html.dark-mode .status { background: var(--dark-hover); color: var(--dark-text); }
html.dark-mode .certificate-preview,
html.dark-mode .referral-preview,
html.dark-mode .holiday-preview { background: var(--dark-preview); }
html.dark-mode .certificate-preview .page,
html.dark-mode .referral-preview .page { background: #fff; color: #20242b; }

/* Employee list table */
.table-card { overflow-x: auto; }
.employee-table { min-width: 880px; }
.employee-table th { text-align: center; }
.employee-table th,
.employee-table td { vertical-align: middle; }
.employee-actions { display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px; white-space: nowrap; }
.employee-actions form { display: inline-flex; margin: 0; }
.employee-action { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 0 9px; border: 1px solid var(--works-line); border-radius: 8px; background: var(--works-elevated); color: var(--works-text); font: inherit; font-size: 12px; line-height: 1; cursor: pointer; }
.employee-action.danger { color: var(--works-danger); border-color: var(--works-danger-border); }
html.dark-mode .employee-action { background: var(--dark-control); border-color: var(--dark-border); color: var(--dark-text); }
html.dark-mode .employee-action.danger { color: var(--works-danger); }
.pdf-option input[type=checkbox] { width: auto; margin: 0; accent-color: var(--works-primary); }
html.dark-mode .pdf-option input[type=checkbox] { accent-color: var(--dark-accent); }

/* Shared fixed-position notifications and confirmation dialog */
.works-toast-region {
    position: fixed;
    z-index: 2000;
    top: 18px;
    right: 18px;
    width: min(420px, calc(100vw - 36px));
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    pointer-events: none;
}
.works-toast {
    position: relative;
    margin-bottom: 10px;
    padding: 15px 44px 15px 16px;
    border: 1px solid var(--works-line);
    border-left: 4px solid var(--works-info);
    border-radius: 9px;
    background: var(--works-surface);
    color: var(--works-text);
    box-shadow: 0 8px 28px var(--works-shadow);
    pointer-events: auto;
}
.works-toast[data-level="success"] { border-left-color: var(--works-success); }
.works-toast[data-level="warning"] { border-left-color: var(--works-warning); }
.works-toast[data-level="error"] { border-left-color: var(--works-danger); }
.works-toast-message { margin: 0; white-space: pre-line; }
.works-toast-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.works-toast-details { margin-top: 9px; font-size: 12px; }
.works-toast-details summary { cursor: pointer; }
.works-toast-details pre {
    max-height: 30vh;
    overflow: auto;
    margin: 8px 0 0;
    white-space: pre-wrap;
    font: inherit;
}
.works-confirm-layer[hidden] { display: none; }
.works-confirm-layer {
    position: fixed;
    z-index: 2100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgb(4 10 20 / 70%);
}
.works-confirm-panel {
    width: min(440px, 100%);
    padding: 24px;
    border: 1px solid var(--works-line);
    border-radius: 14px;
    background: var(--works-surface);
    color: var(--works-text);
    box-shadow: 0 18px 55px var(--works-shadow);
}
.works-confirm-panel h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.works-confirm-panel p { display: grid; gap: 8px; margin: 0; white-space: pre-line; }
.works-confirm-detail { color: var(--works-muted); font-size: 13px; }
.works-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.works-confirm-actions .button { min-width: 78px; }
.works-confirm-actions .button.danger { border-color: var(--works-danger-border); background: var(--works-danger-surface); color: var(--works-danger); }
html.dark-mode .works-toast,
html.dark-mode .works-confirm-panel {
    border-color: var(--dark-border);
    background: var(--dark-surface);
    color: var(--dark-text);
}
html.dark-mode .works-confirm-detail { color: var(--dark-muted); }
html.dark-mode .works-confirm-actions .button { background: var(--dark-control); border-color: var(--dark-border); color: var(--dark-text); }
html.dark-mode .works-confirm-actions .button.danger { border-color: var(--works-danger-border); background: var(--works-danger-surface); color: var(--works-danger); }

/* Fill the certificate screen's remaining content height. */
body.certificate-page .main { min-height: 100vh; display: flex; flex-direction: column; }
body.certificate-page .content { display: flex; flex: 1 1 auto; min-height: 0; }
body.certificate-page .certificate-workspace { flex: 1 1 auto; min-height: 0; }
body.certificate-page .certificate-preview { flex: 1 1 auto; height: auto; min-height: 0; }
@media (max-width: 700px) {
    body.certificate-page .main { min-height: calc(100vh - 130px); }
}
/* Keep action and PDF buttons aligned in every toolbar. */
.button { height: 40px; line-height: 1; white-space: nowrap; }

/* Keep the certificate workspace inside the viewport and let the preview use the remainder. */
body.certificate-page { height: 100vh; min-height: 0; overflow: hidden; }
body.certificate-page .app-shell { height: 100vh; min-height: 0; overflow: hidden; }
body.certificate-page .main { height: 100vh; min-height: 0; min-width: 0; overflow: hidden; }
body.certificate-page .content { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden; }
body.certificate-page .certificate-workspace { min-width: 0; }
body.certificate-page .certificate-preview { min-width: 0; overflow: hidden; }
.employee-table td { text-align: center; }

@media (max-width: 700px) {
    body.certificate-page { height: auto; min-height: 100vh; overflow: auto; }
    body.certificate-page .app-shell { height: auto; min-height: 100vh; overflow: visible; }
    body.certificate-page .main { height: auto; min-height: calc(100vh - 130px); overflow: visible; }
    body.certificate-page .content { overflow: visible; }
    body.certificate-page .certificate-preview { min-height: 280px; }
}
/* Shared page-heading row height, matched to the employee list. */
.page-header { height: 68px; min-height: 68px; }
.certificate-toolbar { height: 68px; min-height: 68px; }
@media (max-width: 900px) {
    .page-header,
    .certificate-toolbar { height: auto; min-height: 68px; }
}

/* Legacy component dimensions; current shared tokens live in design-system.css. */


html,
body { background: var(--works-page); color: var(--works-text); }

.sidebar {
    background: var(--works-surface);
    border-color: var(--works-line);
    padding: 25px 14px;
}

.sidebar .brand {
    width: 100%;
    padding: 0 14px 14px;
    color: var(--works-text);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.045em;
    text-align: center;
}

.sidebar nav { width: 100%; gap: 3px; }
.sidebar nav a {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--works-muted);
    font-size: 13px;
    text-align: center;
}
.sidebar nav a:hover,
.sidebar nav a.active {
    background: var(--works-selected);
    color: var(--works-text);
}

.user-area { width: 100%; align-items: center; padding: 0 12px; }
.user-actions { width: 100%; justify-content: center; gap: 8px; margin: 12px 0 20px; }
.theme-toggle,
.settings-button {
    width: 32px;
    height: 32px;
    border-color: var(--works-line);
    border-radius: 6px;
    background: var(--works-surface);
    color: var(--works-muted);
}
.theme-toggle:hover,
.settings-button:hover { background: var(--works-hover); }

.content { padding: 34px; }
.page-header { margin-bottom: 22px; }
.page-title {
    margin-bottom: 5px;
    color: var(--works-text);
    font-size: 25px;
    font-weight: 600;
    letter-spacing: -.035em;
}
.page-description { color: var(--works-muted); font-size: 13px; line-height: 1.55; }

.card {
    background: var(--works-surface);
    border-color: var(--works-line);
    border-radius: 10px;
    box-shadow: 0 8px 28px var(--works-shadow);
}
.form-card { padding: 22px; }
.form-grid { gap: 16px; }
.form-grid label,
.holiday-input-grid label,
.attachment-row { gap: 7px; color: var(--works-muted); font-size: 12px; }

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid var(--works-line);
    border-radius: 6px;
    background: var(--works-surface);
    color: var(--works-text);
    font: inherit;
    font-size: 13px;
}
textarea { width: 100%; min-height: 84px; line-height: 1.5; resize: vertical; }
input::placeholder,
textarea::placeholder { color: var(--works-muted); }
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--works-focus);
    outline-offset: 2px;
}

.button {
    min-height: 36px;
    height: 36px;
    padding: 0 13px;
    border-color: var(--works-line);
    border-radius: 5px;
    background: var(--works-surface);
    color: var(--works-text);
    font-size: 12px;
    font-weight: 500;
}
.button:hover { border-color: var(--works-primary); background: var(--works-hover); }
.button.primary {
    border-color: var(--works-primary);
    background: var(--works-primary);
    color: var(--works-primary-text);
}
.button.primary:hover { border-color: var(--works-primary-hover); background: var(--works-primary-hover); }
.button:disabled { opacity: .55; cursor: wait; }
button:disabled { cursor: not-allowed; }
.button.danger { border-color: var(--works-danger-border); color: var(--works-danger); }
.button.danger:hover { border-color: var(--works-danger); background: var(--works-danger-hover); }

body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) table { font-size: 13px; }
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) th,
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) td { padding: 12px 16px; border-color: var(--works-line); }
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) th { background: var(--works-hover); color: var(--works-muted); font-size: 11px; font-weight: 600; }
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) tbody tr:hover { background: var(--works-hover); }
.table-card { border-radius: 9px; }
.empty { padding: 52px 24px; color: var(--works-muted); }

.works-toast-region { top: 16px; right: 16px; }
.works-toast {
    margin-bottom: 9px;
    border-color: var(--works-line);
    border-radius: 8px;
    background: var(--works-surface);
    color: var(--works-text);
    box-shadow: 0 9px 28px var(--works-shadow);
}
.works-toast-message { font-size: 13px; line-height: 1.5; }
.works-confirm-panel {
    border-color: var(--works-line);
    border-radius: 10px;
    background: var(--works-surface);
    color: var(--works-text);
}


html.dark-mode .sidebar,
html.dark-mode .card,
html.dark-mode .form-card,
html.dark-mode .works-toast,
html.dark-mode .works-confirm-panel { background: var(--works-surface); border-color: var(--works-line); }
html.dark-mode .sidebar nav a { color: var(--works-muted); }
html.dark-mode .sidebar nav a:hover { background: var(--works-hover); color: var(--works-text); }
html.dark-mode .sidebar nav a.active { background: var(--works-selected); color: var(--works-text); }
html.dark-mode .theme-toggle,
html.dark-mode .settings-button,
html.dark-mode input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html.dark-mode select,
html.dark-mode textarea,
html.dark-mode .button { background: var(--dark-control); border-color: var(--works-line); color: var(--works-text); }
html.dark-mode .button.primary { background: var(--works-primary); border-color: var(--works-primary); color: var(--works-primary-text); }
html.dark-mode .button.primary:hover { background: var(--works-primary-hover); }
html.dark-mode .button.danger { background: var(--works-danger-surface); border-color: var(--works-danger-border); color: var(--works-danger); }
html.dark-mode body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) th { background: var(--dark-control); color: var(--works-muted); }
html.dark-mode body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) th,
html.dark-mode body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) td { border-color: var(--works-line); }
html.dark-mode body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) tbody tr:hover { background: var(--works-hover); }
html.dark-mode .form-grid label,
html.dark-mode .holiday-input-grid label,
html.dark-mode .attachment-row { color: var(--works-muted); }
html.dark-mode .theme-toggle:hover,
html.dark-mode .settings-button:hover { background: var(--works-hover); }

@media (max-width: 700px) {
    .sidebar { padding: 18px 10px; }
    .sidebar .brand { padding: 0 10px 12px; }
    .sidebar nav a { padding: 9px 10px; font-size: 12px; }
    .content { padding: 24px 18px; }
    .form-card { padding: 18px; }
}

/* Common dark controls and native browser widgets. */
html, body { background: var(--works-page); color: var(--works-text); }
body, input, select, textarea, button { color-scheme: dark; }
body .main, body .content { background: var(--works-page); color: var(--works-text); }
body .sidebar, body .card, body .form-card,
body .works-toast, body .works-confirm-panel {
    background: var(--works-surface);
    border-color: var(--works-line);
    color: var(--works-text);
    box-shadow: none;
}
body .sidebar { border-right-color: var(--works-line); }
body .sidebar .brand, body .page-title { color: var(--works-text); }
body .page-description,
body .form-grid label, body .holiday-input-grid label, body .attachment-row,
body .settings-year-control, body .revenue-summary-controls label { color: var(--works-muted); }
body .sidebar nav a { color: var(--works-muted); }
body .sidebar nav a:hover, body .sidebar nav a:focus-visible,
body .sidebar nav a.active { background: var(--works-selected); color: var(--works-text); }

body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
body select, body textarea {
    background-color: var(--works-control);
    border-color: var(--works-line);
    color: var(--works-text);
}
body input::placeholder, body textarea::placeholder { color: var(--works-subtle); opacity: 1; }
body select option { background: var(--works-surface); color: var(--works-text); }
body select option:checked { background: var(--works-selected); color: var(--works-text); }
body input:not(:disabled):not([type="checkbox"]):not([type="radio"]):not([type="range"]):hover,
body select:not(:disabled):hover, body textarea:not(:disabled):hover { border-color: var(--works-subtle); }
body input:disabled, body select:disabled, body textarea:disabled,
body button:disabled, body .button:disabled {
    color: var(--works-subtle);
    opacity: .58;
    cursor: not-allowed;
}
body input[type="checkbox"], body input[type="radio"], body input[type="range"] {
    accent-color: var(--works-primary);
}
body input[type="file"]::file-selector-button {
    border: 1px solid var(--works-line);
    border-radius: 5px;
    background: var(--works-elevated);
    color: var(--works-text);
    padding: 6px 10px;
    margin-right: 10px;
    cursor: pointer;
}
body input[type="file"]::file-selector-button:hover { background: var(--works-hover); }

body .button, body .theme-toggle, body .settings-button,
body .employee-action {
    background: var(--works-elevated);
    border-color: var(--works-line);
    color: var(--works-text);
}
body .button:hover, body .theme-toggle:hover, body .settings-button:hover,
body .employee-action:hover {
    background: var(--works-hover);
    border-color: var(--works-primary);
    color: var(--works-text);
}
body .button.primary, body .works-confirm-actions .button.primary {
    background: var(--works-primary);
    border-color: var(--works-primary);
    color: var(--works-primary-text);
}
body .button.primary:hover, body .works-confirm-actions .button.primary:hover {
    background: var(--works-primary-hover);
    border-color: var(--works-primary-hover);
    color: var(--works-primary-text);
}
body .button.danger, body .employee-action.danger,
body .works-confirm-actions .button.danger {
    background: var(--works-danger-surface);
    border-color: var(--works-danger-border);
    color: var(--works-danger);
}
body .button.danger:hover, body .employee-action.danger:hover,
body .works-confirm-actions .button.danger:hover {
    background: var(--works-danger-hover);
    border-color: var(--works-danger);
    color: var(--works-danger-hover-text);
}
body button:focus-visible, body a:focus-visible, body input:focus-visible,
body select:focus-visible, body textarea:focus-visible {
    outline-color: var(--works-focus);
}

body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) table { color: var(--works-text); }
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) th {
    background: var(--works-elevated);
    color: var(--works-subtle);
}
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) th,
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) td { border-color: var(--works-line); }
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) tbody tr:hover { background: var(--works-hover); }
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) tbody tr[aria-selected="true"],
body:not(.certificate-page):not(.referral-page):not(.holiday-notice-page) tbody tr.selected { background: var(--works-selected); }
body .empty { color: var(--works-muted); }
body .status { background: var(--works-selected); color: var(--works-info); }
body .status[data-state="success"], body .status.success { background: var(--works-success-surface); color: var(--works-success); }
body .status[data-state="warning"], body .status.warning { background: var(--works-warning-surface); color: var(--works-warning); }
body .status[data-state="error"], body .status.error { background: var(--works-danger-surface); color: var(--works-danger); }

body .attachment-preview { background: var(--works-elevated); }
body .certificate-preview, body .referral-preview, body .holiday-preview {
    background: var(--works-preview-surface);
    border-color: var(--works-line);
}
body .certificate-preview .page, body .referral-preview .page,
body .holiday-preview .holiday-page { background: #fff; color: #20242b; }

body .works-toast { box-shadow: 0 9px 28px var(--works-shadow); }
body .works-toast[data-level="success"] { border-left-color: var(--works-success); }
body .works-toast[data-level="warning"] { border-left-color: var(--works-warning); }
body .works-toast[data-level="error"] { border-left-color: var(--works-danger); }
body .works-toast[data-level="info"] { border-left-color: var(--works-primary); }
body .works-confirm-layer { background: var(--works-overlay); }
body .works-confirm-panel { box-shadow: 0 18px 55px rgb(0 0 0 / 42%); }
body .works-confirm-detail { color: var(--works-muted); }
body .revenue-import-warning { background: var(--works-warning-surface); color: var(--works-warning); }
body .clinic-closure-text, body .revenue-summary-date.closed { color: var(--works-closed); }
body .clinic-early-close-text, body .revenue-summary-date.early-close { color: var(--works-early-close); }
body .revenue-summary-date.saturday { color: var(--works-primary); }

body, body * { scrollbar-color: var(--works-elevated) var(--works-page); }
body ::selection { background: var(--works-selected); color: var(--works-text); }

/* Document preview frames share the same application chrome; the document inside stays untouched. */
.certificate-preview,
.referral-preview,
.holiday-preview {
    border: 1px solid var(--works-line);
    border-radius: 10px;
}

.revenue-import-sections { display: grid; gap: 18px; }
.revenue-import-warning {
    margin: 18px 0 0;
    padding: 11px 13px;
    border-left: 3px solid var(--works-primary);
    border-radius: 4px;
    background: var(--works-hover);
    color: var(--works-muted);
    font-size: 12px;
    line-height: 1.55;
}
.revenue-summary { min-height: 188px; }
.revenue-summary-title { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.revenue-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.revenue-summary-grid > div { min-width: 0; padding: 10px 12px; border: 1px solid var(--works-line); border-radius: 6px; }
.revenue-summary-grid dt { color: var(--works-muted); font-size: 11px; }
.revenue-summary-grid dd { margin: 5px 0 0; color: var(--works-text); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.revenue-missing-days,
.revenue-result { min-height: 1.5em; margin: 12px 0 0; color: var(--works-muted); font-size: 12px; line-height: 1.5; }
.revenue-result { margin-top: 5px; }
@media (max-width: 700px) {
    .revenue-summary-grid { grid-template-columns: 1fr; }
    .revenue-summary-grid > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .revenue-summary-grid dd { margin: 0; text-align: right; }
}

/* Patient lookup additions inherit the existing shell, cards and form controls. */
body.patient-lookup-page .patient-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-right: 18px; border-bottom: 1px solid var(--works-line); }
body.patient-lookup-page .patient-detail-heading .patient-lookup-heading { border: 0; }
body.patient-lookup-page .family-section-title { margin: 0 0 16px; font-size: 16px; font-weight: 500; }
body.patient-lookup-page .family-table { min-width: 700px; }
body.patient-lookup-page .family-table details { white-space: normal; overflow-wrap: anywhere; }
body.patient-lookup-page .family-table summary { cursor: pointer; color: var(--works-muted); }
body.patient-lookup-page #family-editor-message:empty,
body.patient-lookup-page #family-message:empty { display: none; }
body.patient-lookup-page #family-editor { border-bottom: 1px solid var(--works-line); }
body.patient-lookup-page .patient-lookup-workspace { min-width: 0; }
body.patient-lookup-page .patient-search-row label,
body.patient-lookup-page .form-grid > label,
body.patient-lookup-page input,
body.patient-lookup-page select { min-width: 0; }
@media (max-width: 700px) {
    body:is(.patient-lookup-page, .holiday-notice-page, .auth-management-page) .app-shell { flex-direction: column; }
    body:is(.patient-lookup-page, .holiday-notice-page, .auth-management-page) .sidebar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; flex: 0 0 auto; width: 100%; height: auto; padding: 14px 18px; overflow: hidden; }
    body:is(.patient-lookup-page, .holiday-notice-page, .auth-management-page) .sidebar .brand { padding: 0; }
    body:is(.patient-lookup-page, .holiday-notice-page, .auth-management-page) .sidebar .user-area { width: auto; padding: 0; }
    body:is(.patient-lookup-page, .holiday-notice-page, .auth-management-page) .sidebar .user-actions { margin: 0; }
    body:is(.patient-lookup-page, .holiday-notice-page, .auth-management-page) .sidebar nav { grid-column: 1 / -1; display: flex; min-width: 0; overflow-x: auto; }
    body:is(.patient-lookup-page, .holiday-notice-page, .auth-management-page) .sidebar nav a { flex: 0 0 auto; white-space: nowrap; }
    body:is(.patient-lookup-page, .holiday-notice-page, .auth-management-page) .main { flex: 1 1 auto; height: auto; min-height: 0; }
    body.patient-lookup-page .page-header { flex: 0 0 auto; height: auto; }
    body.patient-lookup-page .patient-detail-heading { flex-wrap: wrap; padding-bottom: 14px; }
    body.patient-lookup-page .patient-detail-heading > .button { margin-left: 18px; }
    body.patient-lookup-page #family-editor .form-grid { grid-template-columns: minmax(0, 1fr); }
}

body.patient-lookup-page #family-group > summary { cursor: pointer; }
body.patient-lookup-page #family-group-message:empty { display: none; }

/* Keep the patient lookup work area proportional to its text on desktop. */
@media (min-width: 701px) {
    body.patient-lookup-page > .app-shell .page-header,
    body.patient-lookup-page .patient-lookup-workspace { max-width: 1040px; width: 100%; }
}

/* Shared family editor: the added person's role relative to the reference patient. */
body.patient-lookup-page .family-sentence,
body.patient-lookup-page #family-lookup,
body.patient-lookup-page .family-patient-selection { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
body.patient-lookup-page .family-sentence { margin-bottom: 16px; }
body.patient-lookup-page .family-added-patient { min-width: 0; max-width: 100%; }
body.patient-lookup-page #family-lookup { flex-wrap: nowrap; }
body.patient-lookup-page #family-query { width: 240px; flex: 1 1 auto; }
body.patient-lookup-page #family-type { width: auto; max-width: 100%; }
body.patient-lookup-page #family-candidate,
body.patient-lookup-page #family-reference { overflow-wrap: anywhere; }
