:root {
    --primary: #123f68;
    --primary-dark: #092a48;
    --accent: #16a085;
    --accent-dark: #0f7d69;
    --bg: #f3f7fb;
    --surface: #ffffff;
    --text: #172433;
    --muted: #64748b;
    --border: #dce5ee;
    --danger: #c0392b;
    --warning: #a16207;
    --success: #147d4f;
    --shadow: 0 12px 34px rgba(18, 63, 104, .1);
    --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    min-height: 68px;
    padding: 0 4vw;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    background: linear-gradient(115deg, var(--primary-dark), var(--primary));
    box-shadow: 0 4px 20px rgba(9, 42, 72, .22);
}
.brand { display: inline-flex; gap: 10px; align-items: center; color: #fff; font-weight: 800; font-size: 1.08rem; }
.brand:hover { text-decoration: none; }
.brand-logo-shell {
    width: clamp(190px, 21vw, 270px); height: 48px; padding: 5px 8px;
    justify-content: center; overflow: hidden; border-radius: 9px; background: #fff;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .16);
}
.brand-logo { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-mark {
    width: 38px; height: 38px; display: grid; place-items: center;
    border-radius: 11px; background: var(--accent); color: #fff; letter-spacing: -.03em;
}
.topnav { display: flex; align-items: center; gap: 7px; }
.topnav a { color: #eaf4fb; padding: 9px 12px; border-radius: 8px; font-weight: 650; font-size: .92rem; }
.topnav a:hover { color: #fff; background: rgba(255,255,255,.11); text-decoration: none; }
.topnav .logout-link { border: 1px solid rgba(255,255,255,.35); }
.menu-toggle { display: none; border: 0; background: transparent; color: #fff; font-size: 1.45rem; cursor: pointer; }

.container { width: min(1440px, 94vw); margin: 26px auto 54px; }
.narrow { width: min(760px, 92vw); }
.page-head { display: flex; justify-content: space-between; gap: 18px; align-items: end; margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 3vw, 2.15rem); color: var(--primary-dark); }
.page-head p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: var(--accent-dark); font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.card-head h2 { margin: 0; color: var(--primary-dark); font-size: 1.05rem; }
.card-body { padding: 20px; }
.stat-card { padding: 19px; border-left: 4px solid var(--accent); }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { margin-top: 5px; color: var(--primary-dark); font-weight: 850; font-size: 1.75rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.form-grid > .full { grid-column: 1 / -1; }
label { color: #273c50; font-size: .88rem; font-weight: 700; }
.required::after { content: " *"; color: var(--danger); }
input, select, textarea {
    width: 100%; min-height: 43px; border: 1px solid #cbd8e5; border-radius: 9px;
    padding: 9px 11px; color: var(--text); background: #fff; outline: none;
    transition: border-color .16s, box-shadow .16s;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,160,133,.13); }
input[readonly] { color: #4b647a; background: #edf3f8; }
.hint { color: var(--muted); font-size: .78rem; }
.checkbox-field { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; color: #273c50; font-size: .85rem; font-weight: 650; }
.checkbox-field input { width: 18px; min-width: 18px; height: 18px; min-height: 18px; margin: 2px 0 0; accent-color: var(--accent-dark); }
.actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
    appearance: none; border: 0; border-radius: 9px; padding: 10px 16px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    color: #fff; background: var(--primary); font-weight: 750; font-size: .9rem;
    transition: transform .12s, opacity .12s, background .12s;
}
.btn:hover { color: #fff; text-decoration: none; opacity: .94; transform: translateY(-1px); }
.btn-accent { background: var(--accent-dark); }
.btn-whatsapp { background: #128c4a; }
.btn-danger { background: var(--danger); }
.btn-light { color: var(--primary); background: #eaf1f7; }
.btn-light:hover { color: var(--primary-dark); }
.btn-sm { padding: 7px 10px; font-size: .78rem; border-radius: 7px; }
.inline-form { display: inline-flex; gap: 6px; margin: 0; align-items: center; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { padding: 11px 9px; color: #fff; background: var(--primary); text-align: left; white-space: nowrap; }
td { padding: 11px 9px; border-bottom: 1px solid var(--border); vertical-align: top; }
.compact-table { font-size: .79rem; }
.compact-table th { padding: 9px 6px; font-size: .74rem; letter-spacing: .01em; }
.compact-table td { padding: 8px 6px; vertical-align: middle; }
.compact-table .btn-sm { min-height: 29px; padding: 5px 8px; font-size: .72rem; }
.management-table { min-width: 1180px; }
tbody tr:nth-child(even) { background: #f8fbfd; }
tbody tr:hover { background: #eff8f6; }
.nowrap { white-space: nowrap; }
.table-empty { padding: 35px 15px; color: var(--muted); text-align: center; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; min-width: 120px; }
.row-actions form { margin: 0; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-processing { color: #854d0e; background: #fef3c7; }
.status-done { color: #075985; background: #e0f2fe; }
.status-delivered { color: #5b21b6; background: #ede9fe; }
.status-paid { color: #166534; background: #dcfce7; }
.status-finish { color: #fff; background: var(--accent-dark); }
.role-user { color: #075985; background: #e0f2fe; }
.role-supervisor { color: #5b21b6; background: #ede9fe; }
.role-accounts { color: #854d0e; background: #fef3c7; }
.role-admin { color: #166534; background: #dcfce7; }
.inactive { color: #991b1b; background: #fee2e2; }
.notification-sent { color: #166534; background: #dcfce7; }
.notification-failed { color: #991b1b; background: #fee2e2; }
.notification-skipped { color: #475569; background: #e2e8f0; }
.chat-banner {
    padding: 14px 17px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
    border: 1px solid #b7e5cb; border-left: 4px solid #128c4a; border-radius: 11px; background: #f0fff6;
}
.chat-banner > div { display: flex; flex-direction: column; gap: 3px; }
.chat-banner strong { color: #075e31; }
.chat-banner span { color: var(--muted); font-size: .83rem; }
.notification-config-bar {
    margin-bottom: 20px; padding: 11px 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 11px 18px;
    border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.notification-config-bar > span { display: inline-flex; align-items: center; gap: 7px; }

.filter-bar { padding: 14px 18px; border-bottom: 1px solid var(--border); background: #f7fafc; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr minmax(180px, 1.5fr) auto; gap: 10px; align-items: end; }
.filter-grid input { min-height: 39px; }
.filter-grid label { font-size: .76rem; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, .9fr) minmax(430px, 1.1fr); }
.auth-visual {
    position: relative; overflow: hidden; padding: 8vw; display: flex; flex-direction: column; justify-content: center;
    color: #fff; background: linear-gradient(145deg, rgba(9,42,72,.96), rgba(18,63,104,.92)),
        radial-gradient(circle at 80% 10%, #1ec5a5, transparent 38%);
}
.auth-visual::after { content: ""; position: absolute; width: 330px; height: 330px; right: -120px; bottom: -120px; border: 55px solid rgba(255,255,255,.06); border-radius: 50%; }
.auth-visual h1 { max-width: 540px; margin: 15px 0; font-size: clamp(2.2rem, 4.5vw, 4.6rem); line-height: 1.02; letter-spacing: -.04em; }
.auth-visual p { max-width: 570px; color: #d7e9f7; font-size: 1.05rem; }
.auth-brand { display: flex; gap: 10px; align-items: center; font-weight: 800; letter-spacing: .03em; }
.auth-logo-shell {
    width: min(350px, 90%); padding: 8px 12px; border-radius: 11px; background: #fff;
    box-shadow: 0 7px 24px rgba(0, 0, 0, .22);
}
.auth-company-logo { display: block; width: 100%; height: auto; }
.auth-panel { padding: 50px 6vw; display: grid; place-items: center; background: #fff; }
.auth-box { width: min(520px, 100%); }
.auth-box h2 { margin: 0 0 6px; color: var(--primary-dark); font-size: 1.8rem; }
.auth-box > p { margin: 0 0 24px; color: var(--muted); }
.auth-switch { margin-top: 20px; color: var(--muted); text-align: center; }

.alert, .toast { padding: 12px 15px; border-radius: 9px; font-size: .9rem; }
.alert-error { color: #991b1b; background: #fee2e2; border: 1px solid #fecaca; }
.alert-success { color: #166534; background: #dcfce7; border: 1px solid #bbf7d0; }
.alert-info { color: #075985; background: #e0f2fe; border: 1px solid #bae6fd; }
.toast { position: fixed; z-index: 100; top: 82px; right: 20px; max-width: min(430px, calc(100vw - 40px)); box-shadow: var(--shadow); }
.toast button { float: right; margin-left: 12px; border: 0; background: transparent; color: inherit; font-size: 1.2rem; cursor: pointer; }
.footer { padding: 24px; color: var(--muted); text-align: center; font-size: .82rem; }
.modal { position: fixed; z-index: 80; inset: 0; display: none; padding: 20px; place-items: center; background: rgba(8,25,40,.56); }
.modal.open { display: grid; }
.modal-dialog { width: min(680px, 100%); max-height: 92vh; overflow-y: auto; background: #fff; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.modal-dialog.modal-wide { width: min(820px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; color: var(--primary-dark); }
.modal-head .eyebrow { margin-bottom: 2px; }
.modal-close { border: 0; background: transparent; cursor: pointer; font-size: 1.5rem; color: var(--muted); }
.modal-body { padding: 20px; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: var(--border); }
.detail-item { min-height: 69px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; background: #fff; }
.detail-item > span { color: var(--muted); font-size: .71rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.detail-item > strong { color: var(--primary-dark); font-size: .92rem; overflow-wrap: anywhere; }
.detail-wide { grid-column: 1 / -1; }
.entry-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 13px; border-radius: 10px; background: #eef5f8; }
.entry-summary > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.entry-summary span { color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.entry-summary strong { color: var(--primary-dark); overflow-wrap: anywhere; }
.section-gap { margin-top: 24px; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mini { font-size: .78rem; }

@media (max-width: 980px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: 1fr; }
    .auth-page { grid-template-columns: 1fr; }
    .auth-visual { min-height: 280px; padding: 45px 8vw; }
    .auth-visual h1 { font-size: 2.5rem; }
    .auth-panel { padding: 38px 6vw; }
}

@media (max-width: 760px) {
    .container { width: min(94vw, 680px); margin-top: 18px; }
    .page-head { display: block; }
    .page-head .btn { margin-top: 12px; }
    .grid-2, .grid-4, .form-grid { grid-template-columns: 1fr; }
    .field.full, .form-grid > .full { grid-column: auto; }
    .menu-toggle { display: block; }
    .brand-logo-shell { width: min(190px, 68vw); height: 43px; padding: 5px 7px; }
    .topnav { position: absolute; top: 68px; left: 0; right: 0; display: none; padding: 10px 4vw 15px; background: var(--primary-dark); flex-direction: column; align-items: stretch; }
    .topnav.open { display: flex; }
    .filter-grid { grid-template-columns: 1fr 1fr; }
    .filter-grid .search-field { grid-column: 1 / -1; }
    .filter-grid .filter-actions { grid-column: 1 / -1; }
    .details-grid { grid-template-columns: 1fr; }
    .detail-wide { grid-column: auto; }
    .entry-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    table.responsive thead { display: none; }
    table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
    table.responsive tr { margin: 12px; width: calc(100% - 24px); border: 1px solid var(--border); border-radius: 10px; background: #fff !important; overflow: hidden; }
    table.responsive td { min-height: 39px; padding: 9px 10px 9px 44%; border-bottom: 1px solid #edf1f4; position: relative; }
    table.responsive td::before { content: attr(data-label); position: absolute; left: 10px; width: 39%; color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; }
    table.responsive td:last-child { border-bottom: 0; }
    .table-empty { padding-left: 10px !important; }
    .table-empty::before { display: none; }
    .management-table { min-width: 0; }
    .chat-banner { align-items: stretch; flex-direction: column; }
    .notification-config-bar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 470px) {
    .auth-visual { min-height: 230px; }
    .auth-visual p { display: none; }
    .auth-logo-shell { width: min(285px, 94%); padding: 6px 9px; }
    .auth-panel { padding: 30px 5vw; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-grid .search-field, .filter-grid .filter-actions { grid-column: auto; }
    .entry-summary { grid-template-columns: 1fr; }
    .modal { padding: 8px; }
    .modal-body { padding: 15px; }
    table.responsive td { padding-left: 10px; padding-top: 29px; }
    table.responsive td::before { top: 8px; width: calc(100% - 20px); }
}
