:root {
    --sp-ink: #18232f;
    --sp-muted: #66758a;
    --sp-page: #f4f7fb;
    --sp-card: #ffffff;
    --sp-line: #d9e3ee;
    --sp-primary: #0f766e;
    --sp-primary-dark: #115e59;
    --sp-sidebar: #1f2933;
    --sp-amber: #f59e0b;
    --sp-blue: #2563eb;
    --sp-green: #16a34a;
    --sp-red: #dc2626;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--sp-page);
    color: var(--sp-ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

a {
    color: var(--sp-primary);
    text-decoration: none;
}

a:hover {
    color: var(--sp-primary-dark);
}

.btn {
    border-radius: 6px;
    font-weight: 700;
}

.btn-primary {
    --bs-btn-bg: var(--sp-primary);
    --bs-btn-border-color: var(--sp-primary);
    --bs-btn-hover-bg: var(--sp-primary-dark);
    --bs-btn-hover-border-color: var(--sp-primary-dark);
}

.form-control,
.form-select {
    border-color: var(--sp-line);
    border-radius: 6px;
    min-height: 42px;
}

.form-label {
    color: #334155;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.auth-shell {
    align-items: center;
    background: linear-gradient(135deg, #eef7f6 0%, #f8fafc 52%, #fff7ed 100%);
    display: flex;
    min-height: 100vh;
}

.login-panel {
    margin: 0 auto;
    max-width: 430px;
    padding: 24px;
    width: 100%;
}

.login-card {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .1);
    padding: 32px;
}

.login-logo {
    display: block;
    margin: 0 auto;
    max-height: 92px;
    max-width: 100%;
    object-fit: contain;
}

.login-subtitle {
    color: var(--sp-muted);
    margin: 16px 0 24px;
    text-align: center;
}

.input-icon {
    position: relative;
}

.input-icon i {
    color: #94a3b8;
    left: 14px;
    position: absolute;
    top: 13px;
}

.input-icon .form-control {
    padding-left: 42px;
}

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

.app-sidebar {
    background: var(--sp-sidebar);
    color: #d9e2ec;
    flex: 0 0 264px;
    min-height: 100vh;
    padding: 18px;
    position: sticky;
    top: 0;
}

.brand {
    align-items: center;
    background: #fff;
    border-radius: 8px;
    display: flex;
    height: 64px;
    justify-content: center;
    margin-bottom: 20px;
    padding: 8px;
}

.brand img {
    max-height: 48px;
    max-width: 100%;
    object-fit: contain;
}

.sidebar-user {
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
}

.avatar {
    align-items: center;
    background: #fff7ed;
    border-radius: 50%;
    color: #9a3412;
    display: inline-flex;
    font-weight: 800;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.sidebar-user strong,
.sidebar-user span {
    display: block;
}

.sidebar-user span {
    color: #9fb3c8;
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.sidebar-nav a {
    align-items: center;
    border-radius: 6px;
    color: #d9e2ec;
    display: flex;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
    background: rgba(15, 118, 110, .28);
    color: #fff;
}

.sidebar-nav i {
    text-align: center;
    width: 18px;
}

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

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid var(--sp-line);
    display: flex;
    justify-content: space-between;
    min-height: 68px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-title {
    color: var(--sp-ink);
    font-size: 20px;
    font-weight: 800;
    margin-left: 10px;
}

.sidebar-button {
    display: none;
}

.topbar-user {
    align-items: center;
    display: flex;
    gap: 12px;
}

.content-area {
    padding: 24px;
}

.hero-panel,
.panel {
    background: var(--sp-card);
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    box-shadow: 0 14px 42px rgba(15, 23, 42, .06);
}

.hero-panel {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 24px;
}

.hero-panel.compact {
    margin-bottom: 18px;
}

.hero-panel span {
    color: var(--sp-primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.hero-panel h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 6px 0;
}

.hero-panel p {
    color: var(--sp-muted);
    margin: 0;
}

.hero-actions {
    display: flex;
    gap: 8px;
}

.metric-card {
    background: #fff;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    min-height: 130px;
    padding: 18px;
}

.metric-card i {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    height: 38px;
    justify-content: center;
    margin-bottom: 12px;
    width: 38px;
}

.metric-card span {
    color: var(--sp-muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    font-size: 30px;
    margin-top: 3px;
}

.accent-blue i { background: #dbeafe; color: var(--sp-blue); }
.accent-amber i { background: #fef3c7; color: #b45309; }
.accent-green i { background: #dcfce7; color: var(--sp-green); }
.accent-red i { background: #fee2e2; color: var(--sp-red); }

.panel {
    padding: 18px;
}

.sticky-panel {
    position: sticky;
    top: 92px;
}

.panel-header {
    align-items: center;
    border-bottom: 1px solid var(--sp-line);
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
}

.panel-header h2 {
    font-size: 17px;
    font-weight: 800;
    margin: 0;
}

.panel-header span {
    color: var(--sp-muted);
}

.table {
    margin-bottom: 0;
}

.table th {
    color: #475569;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.table td {
    border-color: #e5edf4;
}

.table-actions {
    white-space: nowrap;
}

.muted {
    color: var(--sp-muted);
    font-size: 12px;
}

.empty-row {
    color: var(--sp-muted);
    padding: 28px !important;
    text-align: center;
}

.value-block span,
.value-block strong {
    display: block;
}

.value-block span {
    color: var(--sp-muted);
    font-weight: 700;
}

.value-block strong {
    font-size: 30px;
    margin-top: 8px;
}

.invoice-summary-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.invoice-total-card {
    background: #fff;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    min-height: 108px;
    padding: 16px;
}

.invoice-total-card span {
    color: var(--sp-muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.invoice-total-card strong {
    display: block;
    font-size: 24px;
    margin-top: 10px;
}

.invoice-total-card.primary {
    background: #102a43;
    border-color: #102a43;
    color: #fff;
}

.invoice-total-card.primary span {
    color: #bcccdc;
}

.item-description {
    min-width: 220px;
    white-space: normal;
}

.rich-text-preview {
    color: #1f2937;
    line-height: 1.35;
}

.rich-text-preview p {
    margin: 0 0 6px;
}

.rich-text-preview p:last-child {
    margin-bottom: 0;
}

.rich-text-preview ul,
.rich-text-preview ol {
    margin: 0 0 6px 18px;
    padding: 0;
}

.rich-text-preview li {
    margin-bottom: 3px;
}

.mce-tinymce {
    border-color: var(--sp-line) !important;
    border-radius: 6px;
    overflow: hidden;
}

.rich-text-editor-fallback {
    border-color: #f59e0b;
}

.workflow-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.workflow-actions form {
    margin: 0;
}

.config-preview span,
.config-preview strong {
    display: block;
}

.config-preview span {
    color: var(--sp-muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.config-preview strong {
    font-size: 20px;
    margin-top: 8px;
}

.config-preview p {
    color: var(--sp-muted);
    margin: 4px 0 14px;
}

.config-preview dl {
    border-top: 1px solid var(--sp-line);
    display: grid;
    gap: 8px 12px;
    grid-template-columns: auto 1fr;
    margin: 0;
    padding-top: 14px;
}

.config-preview dt {
    color: #475569;
    font-weight: 800;
}

.config-preview dd {
    margin: 0;
    text-align: right;
}

@media (max-width: 900px) {
    .app-sidebar {
        bottom: 0;
        left: 0;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        transition: transform .18s ease;
        z-index: 30;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-button {
        display: inline-flex;
    }

    .topbar {
        padding: 0 16px;
    }

    .content-area {
        padding: 16px;
    }

    .hero-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-user span {
        display: none;
    }

    .invoice-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .invoice-summary-grid {
        grid-template-columns: 1fr;
    }

    .workflow-actions .btn,
    .workflow-actions form {
        width: 100%;
    }
}
