/**
 * Medical Production 117
 * Shared application primitives only.
 * Page/module layout belongs in its own stylesheet; shell/sidebar/header live in dedicated shared files.
 */
:root {
    --navy: #102b46;
    --navy-2: #173d60;
    --blue: #176dcc;
    --blue-dark: #0f5cac;
    --page: #f4f7fb;
    --surface: #ffffff;
    --border: #d9e2ec;
    --text: #142033;
    --muted: #607086;
    --success: #168553;
    --danger: #bd3434;
    --shadow: 0 16px 36px rgba(24, 49, 79, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body {
    min-height: 100dvh;
    margin: 0;
    color: var(--text);
    background: var(--page);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 14.5px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none; }

.app-shell { min-height: 100dvh; display: flex; }
.content { flex: 1; min-width: 0; padding: 28px 30px; }
.footer {
    width: 100%;
    align-self: stretch;
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 24px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}
.page-header > :first-child { min-width: 0; }
.page-header h1 { margin: 0; font-size: clamp(24px, 2.2vw, 29px); letter-spacing: -.025em; }
.page-subtitle { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }
.page-header-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.form-panel { overflow: hidden; }
.form-section { padding: 24px; }
.form-section + .form-section { border-top: 1px solid var(--border); }
.section-heading h2 { margin: 0 0 18px; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-field { display: grid; gap: 8px; min-width: 0; }
.form-field > span { font-weight: 650; }
.form-field b { color: var(--danger); }
.form-field input,
.form-field select,
.form-field textarea,
.filter-bar input,
.filter-bar select {
    width: 100%;
    padding: 13px 14px;
    color: var(--text);
    border: 1px solid #cbd8e6;
    border-radius: 10px;
    outline: 0;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.filter-bar input:focus,
.filter-bar select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(23, 109, 204, .12);
}
.form-field textarea { resize: vertical; }
.full-span { grid-column: 1 / -1; }
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
}
.compact-form { max-width: 680px; padding: 22px; display: grid; gap: 18px; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background-color .15s ease, color .15s ease;
}
.button:hover:not(:disabled):not([aria-disabled="true"]) { transform: translateY(-1px); }
.button:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(0) scale(.99); }
.button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
.pagination a:focus-visible {
    outline: 3px solid rgba(23, 109, 204, .24);
    outline-offset: 2px;
}
.button.primary { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 6px 14px rgba(23, 109, 204, .13); }
.button.primary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--blue-dark); border-color: var(--blue-dark); box-shadow: 0 9px 18px rgba(15, 92, 172, .18); }
.button.secondary { color: #17324e; background: #fff; border-color: #cfdbe7; }
.button.secondary:hover:not(:disabled):not([aria-disabled="true"]) { color: #0f5cac; background: #f2f8ff; border-color: #9fc4e8; box-shadow: 0 7px 16px rgba(24, 72, 118, .08); }
.button.danger,
.button.danger-outline { color: #a62f2f; background: #fff; border-color: #dfbaba; }
.button.danger:hover:not(:disabled),
.button.danger-outline:hover:not(:disabled) { background: #fff4f4; border-color: #cd7f7f; }
.button:disabled,
.button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.button.compact { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.full-button { width: 100%; }
.icon-button { border: 0; background: transparent; font-size: 23px; cursor: pointer; }
.text-link,
.text-button { color: var(--blue); font-weight: 700; }
.text-button { padding: 0; border: 0; background: transparent; cursor: pointer; }

.alert { margin-bottom: 18px; padding: 13px 16px; border: 1px solid; border-radius: 10px; font-size: 13.5px; line-height: 1.45; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-success { color: #14683f; border-color: #bde8d2; background: #eefaf4; }
.alert-error { color: #8e2929; border-color: #efc3c3; background: #fff1f1; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.metric-card { display: grid; gap: 10px; padding: 22px; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.metric-card strong { font-size: 30px; }
.metric-label { color: var(--muted); }
.status-text { margin: 6px 0 0; color: var(--muted); }

.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) 170px 110px auto; gap: 12px; margin-bottom: 18px; padding: 16px; }
.table-panel { overflow: hidden; }
.table-meta { padding: 14px 18px; color: var(--muted); border-bottom: 1px solid var(--border); }
.table-scroll { overflow: auto; }
table { width: 100%; min-width: 780px; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid #e7edf4; }
th { color: #536379; background: #f8fafc; font-size: 13px; }
tbody tr { transition: background-color .14s ease; }
tbody tr:hover { background: #fbfdff; }
.table-subtext { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.empty-cell { padding: 34px; color: var(--muted); text-align: center; }
.empty-state { padding: 40px; text-align: center; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions form { margin: 0; }
.status-badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-badge.active { color: #147047; background: #eaf8f1; }
.status-badge.archived { color: #5b6573; background: #eef1f4; }
.pagination { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.pagination a { min-width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.pagination a:hover { border-color: #a7c5e3; background: #f5f9fd; }
.pagination a.active { color: #fff; border-color: var(--blue); background: var(--blue); }

/* Production 116: global page-purpose hierarchy for record/list/report/history workspaces.
   Primary data stays first; sibling workflow/navigation actions belong after the content. */
.page-next-actions {
    display: grid;
    gap: 10px;
    margin-top: 20px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(24, 49, 79, .05);
}
.page-next-actions-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.page-next-actions-copy strong { color: var(--navy); font-size: 14px; }
.page-next-actions-copy span { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.page-next-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.page-next-actions-grid .button { width: 100%; min-width: 0; min-height: 40px; justify-content: center; padding: 8px 11px; font-size: 12px; }
.page-next-actions-grid .button.primary { box-shadow: none; }
@media (max-width: 420px) {
    .page-next-actions { margin-top: 16px; padding: 12px; }
    .page-next-actions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-next-actions-grid .button { min-height: 38px; padding: 7px 8px; font-size: 10.8px; line-height: 1.25; }
}

/* Authentication screen primitives remain shared because login does not use the authenticated shell. */
.login-body { min-height: 100dvh; display: grid; place-items: center; padding: 22px; background: linear-gradient(135deg, #0f2a45, #1e5682); }
.login-card { width: min(460px, 100%); padding: 28px; border-radius: 18px; background: #fff; box-shadow: 0 24px 60px rgba(0, 0, 0, .24); }
.login-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.login-brand h1 { margin: 0; font-size: 23px; }
.login-brand p { margin: 5px 0 0; color: var(--muted); }
.login-form { display: grid; gap: 18px; }

@media (max-width: 1100px) {
    .form-grid.three-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .content { padding: 20px 14px; }
    .footer { padding: 13px 14px; }
    .filter-bar { grid-template-columns: 1fr 1fr; }
    .filter-bar input { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
    .form-grid,
    .form-grid.three-columns,
    .metric-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 13px; }
    .page-header-actions { width: 100%; justify-content: flex-end; }
    .page-header-actions .button { width: auto; }

    .form-section,
    .form-actions { padding: 18px; }
    .form-actions { flex-direction: column-reverse; align-items: stretch; }
    .form-actions .button { width: 100%; }
    .filter-bar { grid-template-columns: 1fr; }
    .filter-bar input { grid-column: auto; }
    .footer { flex-direction: column; gap: 4px; }
}

/* Reusable structured form controls consumed by Seller, Vendor, Customer, Price Header and Sales forms. */
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.field-control { position: relative; display: block; min-width: 0; }
.field-control > .field-leading-icon { position: absolute; z-index: 1; top: 50%; left: 13px; width: 19px; height: 19px; display: grid; place-items: center; color: #60778d; transform: translateY(-50%); pointer-events: none; }
.field-control > .field-leading-icon svg { width: 18px; height: 18px; }
.field-control > input,
.field-control > select,
.field-control > textarea { padding-left: 43px; }
.field-control:has(textarea) > .field-leading-icon { top: 18px; transform: none; }
.form-field input[aria-invalid="true"],
.form-field select[aria-invalid="true"],
.form-field textarea[aria-invalid="true"] { border-color: #d24a4a; box-shadow: 0 0 0 3px rgba(210, 74, 74, .1); }
.form-error-summary { display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px; }
.form-error-summary .alert-semantic-icon { width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; color: #fff; border-radius: 50%; background: #b83232; font-weight: 800; }
.form-error-summary strong { display: block; margin: 1px 0 5px; }
.form-error-summary ul { margin: 0; padding-left: 18px; }
.lookup-suggestion-field { position: relative; }
.lookup-suggestions { position: absolute; z-index: 35; top: calc(100% - 2px); right: 0; left: 0; max-height: 220px; overflow-y: auto; border: 1px solid #b9c9d8; border-radius: 0 0 10px 10px; background: #fff; box-shadow: 0 12px 26px rgba(15, 40, 64, .16); }
.lookup-suggestion-option { width: 100%; display: block; padding: 10px 12px; color: #173552; border: 0; border-bottom: 1px solid #e4ebf1; background: #fff; text-align: left; cursor: pointer; }
.lookup-suggestion-option:hover,
.lookup-suggestion-option:focus { outline: 0; background: #edf6ff; }
.field-feedback,
.lookup-status { width: fit-content; max-width: 100%; display: flex; align-items: flex-start; gap: 7px; margin: 2px 0 0; padding: 7px 9px; color: #60758a; border: 1px solid transparent; border-radius: 8px; font-size: 12.5px; line-height: 1.35; }
.field-feedback.is-error,
.lookup-status[data-lookup-state="error"] { color: #982f2f; border-color: #efc3c3; background: #fff1f1; }
.lookup-status[data-lookup-state="warning"] { color: #825d00; border-color: #f0d38d; background: #fff8e6; }
.lookup-status[data-lookup-state="success"] { color: #126c42; border-color: #bce3cb; background: #edf9f2; }
.lookup-status[data-lookup-state="loading"],
.lookup-status[data-lookup-state="ready"] { color: #205a86; border-color: #bfd7ed; background: #eef6ff; }
.lookup-status[data-lookup-state]::before { font-weight: 800; line-height: 1.2; }
.lookup-status[data-lookup-state="success"]::before { content: "✓"; }
.lookup-status[data-lookup-state="warning"]::before,
.lookup-status[data-lookup-state="error"]::before { content: "!"; }
.lookup-status[data-lookup-state="loading"]::before { content: "…"; }
.address-workflow-section { display: grid; gap: 18px; }
.address-workflow-section > .section-heading { margin-bottom: -2px; }
.shipping-choice { margin-top: 20px; padding: 14px 16px; border: 1px solid #d6e2ee; border-radius: 11px; background: #f8fbff; }
.address-same-toggle { display: flex; align-items: center; gap: 11px; font-weight: 700; cursor: pointer; }
.address-same-toggle input { width: 20px; height: 20px; accent-color: var(--blue); }
.shipping-address-panel { display: grid; gap: 16px; margin-top: 16px; padding-top: 18px; border-top: 1px solid var(--border); }
.subsection-heading h3 { margin: 0; font-size: 17px; }
@media (max-width: 620px) {
    .field-control > .field-leading-icon { left: 12px; }
    .field-control > input,
    .field-control > select,
    .field-control > textarea { padding-left: 40px; }
    .shipping-choice { padding: 12px; }
}


/* Shared physical-device fallback for generic authenticated content primitives. */
html.mobile-hardware .content { padding: 18px 12px; }
html.mobile-hardware .footer { flex-direction: column; gap: 4px; padding: 12px; }
html.mobile-hardware .form-grid,
html.mobile-hardware .form-grid.three-columns,
html.mobile-hardware .metric-grid,
html.mobile-hardware .filter-bar { grid-template-columns: 1fr; }
html.mobile-hardware .filter-bar input { grid-column: auto; }
html.mobile-hardware .page-header { flex-direction: column; align-items: flex-start; }
html.mobile-hardware .page-header-actions { width: 100%; justify-content: flex-end; }
