/*
 * DBS Smart Intakes Enterprise UI Foundation v1
 * Shared professional sizing and responsive behavior.
 */

:root {
    --dbs-ui-font:
        Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --dbs-ui-text: #1f2937;
    --dbs-ui-muted: #667085;
    --dbs-ui-heading: #102a43;
    --dbs-ui-border: #d8e1ea;
    --dbs-ui-surface: #ffffff;
    --dbs-ui-soft: #f7f9fc;
    --dbs-ui-primary: #0b4f87;
    --dbs-ui-orange: #ef7d22;
    --dbs-ui-danger: #b42318;

    --dbs-ui-radius: 9px;
    --dbs-ui-card-radius: 12px;
    --dbs-ui-control-height: 40px;
    --dbs-ui-content-max: 1600px;
}

/* ---------- Global typography ---------- */

html {
    width: 100%;
    max-width: 100%;
    font-size: 15px;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    margin: 0;
    color: var(--dbs-ui-text);
    font-family: var(--dbs-ui-font);
    font-size: 1rem;
    line-height: 1.5;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
}

body,
button,
input,
select,
textarea {
    font-family: var(--dbs-ui-font);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--dbs-ui-heading);
    line-height: 1.22;
    overflow-wrap: anywhere;
}

h1 {
    margin: 0 0 0.55rem;
    font-size: clamp(1.55rem, 1.5vw + 0.7rem, 2rem);
    font-weight: 700;
}

h2 {
    margin: 0 0 0.65rem;
    font-size: clamp(1.2rem, 0.8vw + 0.8rem, 1.45rem);
    font-weight: 650;
}

h3 {
    margin: 0 0 0.55rem;
    font-size: 1.08rem;
    font-weight: 650;
}

h4,
h5,
h6 {
    font-size: 1rem;
}

p,
li,
td,
label,
input,
select,
textarea,
button,
a {
    font-size: 0.94rem;
}

small,
.note,
.muted,
.help,
.helper,
.description {
    color: var(--dbs-ui-muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.hero h1,
.hero-panel h1,
[class*="hero"] h1 {
    font-size: clamp(1.55rem, 1.5vw + 0.7rem, 2rem) !important;
}

.hero p,
.hero-panel p,
[class*="hero"] p {
    max-width: 920px;
    font-size: 0.96rem !important;
    line-height: 1.55;
}

/* ---------- Media and containment ---------- */

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
    height: auto;
}

main,
section,
article,
header,
footer,
nav,
aside,
div {
    min-width: 0;
}

main,
.main,
.content,
.main-content,
.workspace,
.workspace-content,
.page-content,
.v15-content,
.v60-main {
    max-width: 100%;
}

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

form {
    max-width: 100%;
}

label {
    display: block;
    margin-bottom: 0.32rem;
    color: #344054;
    font-weight: 600;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
    width: 100%;
    max-width: 100%;
    min-height: var(--dbs-ui-control-height);
    padding: 8px 11px;
    color: var(--dbs-ui-text);
    background: #fff;
    border: 1px solid #bfcbd7;
    border-radius: 7px;
    box-sizing: border-box;
    outline: none;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--dbs-ui-primary);
    box-shadow: 0 0 0 3px rgba(11, 79, 135, 0.12);
}

input[type="checkbox"],
input[type="radio"] {
    width: 17px;
    height: 17px;
    margin-right: 6px;
    vertical-align: -3px;
}

fieldset {
    min-width: 0;
    margin: 0 0 18px;
    padding: 16px;
    border: 1px solid var(--dbs-ui-border);
    border-radius: var(--dbs-ui-card-radius);
}

legend {
    padding: 0 7px;
    color: var(--dbs-ui-heading);
    font-size: 0.95rem;
    font-weight: 650;
}

/* ---------- Buttons and action links ---------- */

button,
.btn,
.smallbtn,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--dbs-ui-control-height);
    max-width: 100%;
    padding: 8px 14px;
    border-radius: 7px;
    border: 1px solid transparent;
    box-sizing: border-box;
    font-size: 0.9rem !important;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: normal;
    cursor: pointer;
}

.smallbtn {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.82rem !important;
}

button.large,
.btn.large,
.large.btn {
    min-height: 42px;
    padding: 9px 15px;
    font-size: 0.92rem !important;
}

.actions,
.form-actions,
.toolbar,
.btn-group,
.button-group,
.v58-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 100%;
}

/* ---------- Cards and panels ---------- */

.card,
.panel,
.box,
.hero,
.hero-panel,
[class*="card"],
[class*="panel"] {
    max-width: 100%;
    box-sizing: border-box;
}

.card,
.panel,
.box {
    padding: 18px;
    border-radius: var(--dbs-ui-card-radius);
}

.hero,
.hero-panel {
    padding: clamp(18px, 2vw, 26px);
}

.grid,
.row,
.cards,
.dashboard-grid,
.workflow-grid,
.v58-status-grid,
.v58-steps {
    max-width: 100%;
}

.metric {
    font-size: clamp(1.65rem, 2vw, 2.15rem) !important;
    line-height: 1.1;
}

/* ---------- Tables ---------- */

.dbs-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    padding: 10px 11px;
    font-size: 0.82rem;
    font-weight: 650;
    line-height: 1.3;
    text-align: left;
    white-space: nowrap;
}

td {
    padding: 10px 11px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.scroll,
.table-wrap,
.table-responsive,
.v585-sheet-wrap,
.v15-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Dialogs ---------- */

dialog,
.modal,
.modal-content,
[role="dialog"] {
    max-width: min(92vw, 760px);
    max-height: 88vh;
    overflow: auto;
    box-sizing: border-box;
}

/* ---------- Tablet ---------- */

@media (max-width: 1199px) {
    .grid,
    .dashboard-grid,
    .cards,
    .workflow-grid {
        grid-template-columns:
            repeat(auto-fit, minmax(min(260px, 100%), 1fr)) !important;
    }

    .row {
        flex-wrap: wrap;
    }

    .card,
    .panel,
    .box {
        padding: 16px;
    }

    [style*="grid-template-columns"] {
        max-width: 100%;
    }
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
    html {
        font-size: 14px;
    }

    body {
        width: 100%;
        max-width: 100%;
    }

    h1,
    .hero h1,
    .hero-panel h1,
    [class*="hero"] h1 {
        font-size: 1.6rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    .hero,
    .hero-panel {
        padding: 17px 14px;
    }

    .card,
    .panel,
    .box,
    [class*="card"] {
        padding: 14px;
        border-radius: 10px;
    }

    .grid,
    .row,
    .cards,
    .dashboard-grid,
    .workflow-grid,
    .v58-status-grid,
    .v58-steps,
    [class*="grid"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .actions,
    .form-actions,
    .toolbar,
    .btn-group,
    .button-group,
    .v58-actions {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100%;
        gap: 8px;
    }

    .actions > *,
    .form-actions > *,
    .toolbar > *,
    .btn-group > *,
    .button-group > *,
    .v58-actions > * {
        width: 100%;
        max-width: 100%;
    }

    form[style*="display:flex"],
    form[style*="display: flex"] {
        flex-wrap: wrap !important;
    }

    button,
    .btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 42px;
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea {
        min-height: 42px;
        font-size: 16px;
    }

    th,
    td {
        padding: 9px 9px;
    }

    fieldset {
        padding: 13px;
    }

    .nowrap {
        white-space: normal !important;
    }
}

/* ---------- Narrow phones ---------- */

@media (max-width: 430px) {
    .card,
    .panel,
    .box,
    [class*="card"] {
        padding: 12px;
    }

    .hero,
    .hero-panel {
        padding: 15px 12px;
    }

    h1,
    .hero h1,
    .hero-panel h1,
    [class*="hero"] h1 {
        font-size: 1.48rem !important;
    }
}
