/* =========================================================
   HOMEBASE
   Rebrand Design System
   Stein Works
   ========================================================= */


/* =========================================================
   DESIGN TOKENS
   ========================================================= */

:root {
    --ink: #17202a;
    --muted: #667085;

    --line: #e6e9ee;
    --line-strong: #d0d5dd;

    --bg: #f4f6f8;
    --card: #ffffff;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #eff4ff;

    --nav: #101828;
    --nav-hover: #1d2939;
    --nav-text: #d0d5dd;
    --nav-muted: #98a2b3;

    --danger: #b42318;
    --danger-bg: #fee4e2;

    --success: #067647;
    --success-bg: #dcfae6;

    --warning: #b54708;
    --warning-bg: #fef0c7;

    --shadow:
        0 1px 3px rgba(16, 24, 40, .06),
        0 1px 2px rgba(16, 24, 40, .04);

    --shadow-lg:
        0 12px 32px rgba(16, 24, 40, .12);

    --sidebar-width: 252px;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 14px;
}


/* =========================================================
   RESET / GLOBAL
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family:
        Inter,
        "Segoe UI",
        Arial,
        sans-serif;

    background: var(--bg);
    color: var(--ink);

    line-height: 1.45;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: none;
}

img {
    max-width: 100%;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
}


/* =========================================================
   APPLICATION SHELL
   ========================================================= */

.app-shell {
    min-height: 100vh;
}


/* =========================================================
   SIDEBAR
   ========================================================= */

.app-sidebar {
    position: fixed;

    top: 0;
    bottom: 0;
    left: 0;

    width: var(--sidebar-width);

    display: flex;
    flex-direction: column;

    padding: 22px 16px 16px;

    background: var(--nav);
    color: #fff;

    z-index: 100;
}


/* =========================================================
   SIDEBAR BRAND
   ========================================================= */

.sidebar-brand {
    display: flex;
    align-items: center;

    gap: 12px;

    padding: 2px 8px 24px;
}

.sidebar-logo {
    width: 54px;
    height: 54px;

    flex: 0 0 54px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    background: #fff;

    border-radius: 12px;

    padding: 5px;
}

.sidebar-logo img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;
}

.sidebar-brand-text {
    min-width: 0;

    display: flex;
    flex-direction: column;

    line-height: 1.2;
}

.sidebar-brand-text strong {
    color: #fff;

    font-size: 15px;
    font-weight: 700;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-brand-text span {
    margin-top: 4px;

    color: var(--nav-muted);

    font-size: 11px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* =========================================================
   SIDEBAR SECTIONS
   ========================================================= */

.sidebar-section {
    margin-bottom: 22px;
}

.sidebar-section-label {
    padding: 0 12px 7px;

    color: #667085;

    font-size: 10px;
    font-weight: 700;

    letter-spacing: .08em;
    text-transform: uppercase;
}


/* =========================================================
   SIDEBAR NAVIGATION
   ========================================================= */

.sidebar-nav {
    display: grid;

    gap: 4px;
}

.sidebar-nav a,
.sidebar-logout {
    min-height: 42px;

    display: flex;
    align-items: center;

    gap: 10px;

    padding: 10px 12px;

    border-radius: 9px;

    color: var(--nav-text);

    font-size: 14px;
    font-weight: 500;

    text-decoration: none;

    transition:
        background .15s ease,
        color .15s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active,
.sidebar-logout:hover {
    background: var(--nav-hover);
    color: #fff;
}

.nav-icon {
    width: 18px;
    height: 18px;

    flex: 0 0 18px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 18px;
    height: 18px;

    fill: none;

    stroke: currentColor;
    stroke-width: 1.8;

    stroke-linecap: round;
    stroke-linejoin: round;
}


/* =========================================================
   SIDEBAR FOOTER
   ========================================================= */

.sidebar-footer {
    margin-top: auto;

    padding-top: 18px;

    border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-user {
    display: flex;
    align-items: center;

    gap: 10px;

    padding: 0 8px 14px;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;

    flex: 0 0 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: var(--nav-hover);

    color: #fff;

    font-size: 13px;
    font-weight: 700;
}

.sidebar-user-info {
    min-width: 0;

    display: flex;
    flex-direction: column;
}

.sidebar-user-info strong {
    color: #fff;

    font-size: 13px;
    font-weight: 600;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-info span {
    margin-top: 1px;

    color: var(--nav-muted);

    font-size: 11px;
}

.sidebar-footer-links {
    display: flex;
    align-items: center;

    gap: 12px;

    padding: 2px 8px 10px;
}

.sidebar-footer-links a {
    color: var(--nav-muted);

    font-size: 11px;

    text-decoration: none;
}

.sidebar-footer-links a:hover {
    color: #fff;
}

.sidebar-logout {
    width: 100%;

    border: 0;
}


/* =========================================================
   MAIN APPLICATION
   ========================================================= */

.app-main {
    min-height: 100vh;

    margin-left: var(--sidebar-width);
}


/* =========================================================
   TOP BAR
   ========================================================= */

.app-topbar {
    position: sticky;

    top: 0;

    z-index: 50;

    height: 76px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding: 0 30px;

    background: rgba(255, 255, 255, .96);

    border-bottom: 1px solid var(--line);

    backdrop-filter: blur(10px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
}

.topbar-left {
    min-width: 0;

    gap: 16px;
}

.topbar-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 6px;

    padding: 8px 10px;

    border: 1px solid transparent;
    border-radius: 8px;

    background: transparent;

    color: var(--muted);

    font: inherit;
    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background .15s ease,
        color .15s ease,
        border-color .15s ease;
}

.topbar-back:hover {
    background: #f9fafb;

    border-color: var(--line);

    color: var(--ink);
}

.topbar-divider {
    width: 1px;
    height: 30px;

    background: var(--line);
}

.topbar-title {
    min-width: 0;
}

.topbar-title h1 {
    margin: 0;

    color: var(--ink);

    font-size: 21px;
    font-weight: 700;

    line-height: 1.2;
}

.topbar-title span {
    display: block;

    margin-top: 2px;

    color: var(--muted);

    font-size: 11px;
}

.topbar-user {
    color: var(--muted);

    font-size: 13px;
    font-weight: 500;

    white-space: nowrap;
}


/* =========================================================
   CONTENT
   ========================================================= */

.app-content {
    width: 100%;

    padding: 28px;
}

.container {
    width: 100%;
    max-width: 1500px;

    margin: 0 auto;
    padding: 0;
}


/* =========================================================
   CARDS
   ========================================================= */

.card {
    background: var(--card);
    color: var(--ink);

    border: 1px solid var(--line);
    border-radius: var(--radius-lg);

    padding: 20px;

    box-shadow: var(--shadow);
}

.page-card {
    min-height: 120px;
}


/* Generic nested cards */

.card .card {
    box-shadow: none;
}


/* =========================================================
   HEADINGS
   ========================================================= */

h1,
h2,
h3,
h4 {
    color: var(--ink);
}

h1 {
    font-size: 22px;
}

h2 {
    font-size: 18px;
}

h3 {
    font-size: 16px;
}

h1,
h2,
h3 {
    margin-top: 0;
}

.muted {
    color: var(--muted);
}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
    min-height: 40px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 6px;

    padding: 9px 14px;

    border: 1px solid var(--line-strong);
    border-radius: 9px;

    background: #fff;

    color: var(--ink);

    font: inherit;
    font-size: 14px;
    font-weight: 600;

    line-height: 1.2;

    cursor: pointer;

    text-decoration: none;

    transition:
        background .15s ease,
        border-color .15s ease,
        color .15s ease,
        box-shadow .15s ease,
        transform .05s ease;
}

.btn:hover {
    background: #f9fafb;

    border-color: #b8bec7;

    color: var(--ink);

    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}


/* Primary */

.btn-primary,
.btn.primary {
    background: var(--accent);

    border-color: var(--accent);

    color: #fff;
}

.btn-primary:hover,
.btn.primary:hover {
    background: var(--accent-hover);

    border-color: var(--accent-hover);

    color: #fff;
}


/* Secondary */

.btn-secondary,
.btn.secondary {
    background: #fff;

    border-color: var(--line-strong);

    color: var(--ink);
}


/* Danger */

.btn-danger,
.btn.danger {
    background: var(--danger);

    border-color: var(--danger);

    color: #fff;
}

.btn-danger:hover,
.btn.danger:hover {
    background: #912018;

    border-color: #912018;

    color: #fff;
}


/* Small button */

.btn-sm {
    min-height: 32px;

    padding: 6px 10px;

    border-radius: 7px;

    font-size: 12px;
}


/* =========================================================
   ACTION GROUPS
   ========================================================= */

.actions {
    display: flex;
    align-items: center;

    gap: 8px;

    flex-wrap: wrap;
}


/* =========================================================
   FORMS
   ========================================================= */

label {
    display: block;

    margin-bottom: 6px;

    color: #344054;

    font-size: 13px;
    font-weight: 600;

    letter-spacing: 0;
}

input,
select,
textarea {
    font: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="url"],
textarea,
select {
    width: 100%;

    padding: 10px 11px;

    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);

    outline: none;

    background: #fff !important;
    color: var(--ink) !important;

    transition:
        border-color .15s ease,
        box-shadow .15s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #84adff;

    box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #98a2b3;
}


/* =========================================================
   LEGACY LIGHT FIELDS
   ========================================================= */

.light-fields input[type="text"],
.light-fields input[type="email"],
.light-fields input[type="password"],
.light-fields input[type="tel"],
.light-fields input[type="search"],
.light-fields input[type="number"],
.light-fields input[type="date"],
.light-fields textarea,
.light-fields select {
    background: #fff !important;

    color: var(--ink) !important;

    border: 1px solid var(--line-strong) !important;

    border-radius: var(--radius-sm);
}

.light-fields input:focus,
.light-fields textarea:focus,
.light-fields select:focus {
    outline: none;

    border-color: #84adff !important;

    box-shadow: 0 0 0 3px var(--accent-soft);
}


/* =========================================================
   GRID
   ========================================================= */

.grid {
    display: grid;

    grid-template-columns: repeat(12, minmax(0, 1fr));

    gap: 14px;
}

.col-12 {
    grid-column: span 12;
}

.col-6 {
    grid-column: span 6;
}

.col-4 {
    grid-column: span 4;
}

.col-3 {
    grid-column: span 3;
}


/* Newer two-column form layout */

.row {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 14px;
}

.field {
    margin-bottom: 14px;
}


/* =========================================================
   TABLES
   ========================================================= */

.table-wrap {
    overflow: auto;

    background: #fff;

    border: 1px solid var(--line);
    border-radius: var(--radius);

    box-shadow: var(--shadow);
}

table,
.table {
    width: 100%;

    border-collapse: collapse;

    background: #fff;

    color: var(--ink);
}

table th,
table td,
.table th,
.table td {
    padding: 12px 14px;

    border-bottom: 1px solid var(--line);

    background: #fff;

    color: var(--ink);

    text-align: left;

    font-size: 14px;

    vertical-align: middle;
}

table th,
.table th {
    background: #f9fafb;

    color: #475467;

    font-size: 11px;
    font-weight: 700;

    letter-spacing: .04em;

    text-transform: uppercase;

    white-space: nowrap;
}

table tbody tr:last-child td,
.table tbody tr:last-child td {
    border-bottom: 0;
}

table tbody tr:hover td,
.table tbody tr:hover td {
    background: #fcfcfd;
}

.table th:last-child,
.table td:last-child {
    text-align: right;
}


/* =========================================================
   BADGES
   ========================================================= */

.badge {
    display: inline-flex;
    align-items: center;

    padding: 4px 8px;

    border-radius: 999px;

    background: #eef2ff;

    color: #3538cd;

    font-size: 12px;
    font-weight: 600;
}

.badge.ok,
.badge-success,
.ok {
    background: var(--success-bg);

    color: var(--success);
}

.badge.warn,
.badge-warning,
.warn {
    background: var(--warning-bg);

    color: var(--warning);
}

.badge.bad,
.badge-danger,
.bad {
    background: var(--danger-bg);

    color: var(--danger);
}


/* =========================================================
   ALERTS / FLASH
   ========================================================= */

.flash,
.alert-success {
    margin-bottom: 16px;

    padding: 12px 15px;

    border: 1px solid #abefc6;
    border-radius: 10px;

    background: #ecfdf3;

    color: #05603a;
}

.alert-danger {
    margin-bottom: 16px;

    padding: 12px 15px;

    border: 1px solid #fecdca;
    border-radius: 10px;

    background: #fef3f2;

    color: var(--danger);
}


/* =========================================================
   SEARCH
   ========================================================= */

.searchbar {
    margin-bottom: 12px;
}


/* =========================================================
   LEGACY LIGHT VIEW
   ========================================================= */

.light-view .card,
.light-view .panel,
.light-view .box {
    background: #fff !important;

    color: var(--ink) !important;

    border: 1px solid var(--line);

    border-radius: var(--radius);
}

.light-view .table th,
.light-view .table td {
    background: #fff !important;

    color: var(--ink) !important;
}

.light-view .note-box {
    padding: 12px;

    border: 1px solid var(--line);
    border-radius: var(--radius-sm);

    background: #fff !important;

    color: var(--ink) !important;

    white-space: pre-wrap;
}


/* =========================================================
   MODAL FOUNDATION
   Existing page-specific modals can inherit these values.
   ========================================================= */

.modal,
.client-modal {
    backdrop-filter: blur(2px);
}

.modal-card,
.client-modal-card {
    background: #fff;

    color: var(--ink);

    border: 1px solid var(--line);

    border-radius: var(--radius-lg);

    box-shadow: var(--shadow-lg);
}


/* =========================================================
   INVOICE / DOCUMENT VIEW
   ========================================================= */

.doc-wrap {
    display: flex;

    justify-content: center;

    padding: 8px;
}

.doc {
    width: 816px;
    max-width: 100%;

    padding: 24px 28px;

    border: 1px solid #e5e7eb;
    border-radius: var(--radius);

    background: #fff !important;

    color: #000 !important;

    box-shadow: var(--shadow-lg);
}

.doc h1,
.doc h2,
.doc h3 {
    margin: 0 0 8px;

    color: #000;
}

.doc .muted {
    color: #555;
}

.doc .split {
    display: flex;

    justify-content: space-between;
    align-items: flex-start;

    gap: 12px;
}

.doc .block {
    margin: 10px 0;
}

.doc .kvs {
    font-size: 14px;

    line-height: 1.5;
}

.doc .kvs div {
    margin: 2px 0;
}

.doc table.table {
    margin-top: 10px;

    border: 1px solid #d9d9d9;
}

.doc table.table th,
.doc table.table td {
    border-color: #d9d9d9;

    background: #fff;

    color: #000;
}

.doc .totals {
    max-width: 340px;

    margin-left: auto;
}


/* =========================================================
   FOOTER
   ========================================================= */

.app-footer {
    max-width: 1500px;

    margin: 18px auto 0;

    padding: 4px 2px 18px;

    color: #98a2b3;

    font-size: 11px;

    text-align: center;
}


/* =========================================================
   LOGO COMPATIBILITY
   ========================================================= */

.logo-white-outline img {
    filter:
        drop-shadow(0 0 1px rgba(0, 0, 0, .25))
        drop-shadow(0 0 2px rgba(0, 0, 0, .15));
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1050px) {

    .col-3 {
        grid-column: span 6;
    }

}


@media (max-width: 760px) {

    .app-sidebar {
        position: static;

        width: auto;

        padding: 14px;
    }


    .sidebar-brand {
        padding-bottom: 12px;
    }


    .sidebar-logo {
        width: 44px;
        height: 44px;

        flex-basis: 44px;
    }


    .sidebar-section {
        margin-bottom: 10px;
    }


    .sidebar-section-label {
        display: none;
    }


    .sidebar-nav {
        display: flex;

        gap: 4px;

        overflow-x: auto;

        padding-bottom: 2px;
    }


    .sidebar-nav a {
        flex: 0 0 auto;

        white-space: nowrap;
    }


    .sidebar-footer {
        display: none;
    }


    .app-main {
        margin-left: 0;
    }


    .app-topbar {
        position: static;

        height: 64px;

        padding: 0 16px;
    }


    .topbar-user {
        display: none;
    }


    .topbar-divider {
        display: none;
    }


    .topbar-title h1 {
        font-size: 18px;
    }


    .topbar-title span {
        display: none;
    }


    .app-content {
        padding: 16px;
    }


    .card {
        padding: 16px;
    }


    .grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }


    .col-12,
    .col-6,
    .col-4,
    .col-3 {
        grid-column: span 6;
    }


    .row {
        grid-template-columns: 1fr;
    }


    .actions {
        width: 100%;
    }


    .table-wrap {
        overflow-x: auto;
    }


    .doc {
        padding: 18px;
    }

}


/* =========================================================
   PRINT
   ========================================================= */

@media print {

    html,
    body {
        background: #fff !important;

        color: #000 !important;
    }


    .no-print,
    .app-sidebar,
    .app-topbar,
    .app-footer {
        display: none !important;
    }


    .app-main {
        margin: 0 !important;
    }


    .app-content {
        padding: 0 !important;
    }


    .container {
        max-width: none !important;

        margin: 0 !important;
        padding: 0 !important;
    }


    .page-card {
        padding: 0 !important;

        border: 0 !important;
        border-radius: 0 !important;

        box-shadow: none !important;
    }


    .card {
        box-shadow: none !important;
    }


    .doc {
        width: auto;
        max-width: none;

        padding: 0;

        border: 0;
        border-radius: 0;

        box-shadow: none;
    }


    body * {
        box-shadow: none !important;
    }

}