/* ------------------------------------------------------------
   Sarsali design system
   ------------------------------------------------------------ */
:root {
    --brand-50: #ecfdf5;
    --brand-100: #d1fae5;
    --brand-500: #10b981;
    --brand-600: #059669;
    --brand-700: #047857;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --surface: #ffffff;
    --canvas: #f1f5f9;
    --sidebar-width: 264px;
}

html,
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

body {
    min-height: 100vh;
}

a {
    text-decoration: none;
}

/* ------------------------------------------------------------
   Shell
   ------------------------------------------------------------ */
.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0b1220 0%, #0f172a 55%, #111c31 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
}

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

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 1035;
}

body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
}

.app-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (min-width: 1024px) {
    .app-sidebar {
        transform: none;
    }

    .app-content {
        margin-left: var(--sidebar-width);
    }

    .sidebar-backdrop {
        display: none;
    }
}

/* ------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------ */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.15rem 1.1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981, #0d9488);
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(16, 185, 129, 0.28);
    flex-shrink: 0;
}

.brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.brand-tagline {
    color: #94a3b8;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-close {
    background: transparent;
    border: 0;
    color: #94a3b8;
    font-size: 0.9rem;
    padding: 0.35rem;
    border-radius: 0.4rem;
}

.sidebar-close:hover {
    color: #fff;
    background: rgba(148, 163, 184, 0.15);
}

@media (min-width: 1024px) {
    .sidebar-close {
        display: none;
    }
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.7rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 999px;
}

.sidebar-section {
    font-size: 0.63rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #64748b;
    font-weight: 700;
    padding: 1rem 0.85rem 0.4rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.85rem;
    border-radius: 0.6rem;
    color: #cbd5e1;
    font-size: 0.86rem;
    font-weight: 500;
    margin-bottom: 0.15rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link i {
    font-size: 1rem;
    width: 1.15rem;
    text-align: center;
    color: #94a3b8;
}

.sidebar-link:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #fff;
}

.sidebar-link:hover i {
    color: #e2e8f0;
}

.sidebar-link.active {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.04));
    color: #fff;
    box-shadow: inset 3px 0 0 #10b981;
}

.sidebar-link.active i {
    color: #34d399;
}

.nav-badge {
    background: #f59e0b;
    color: #451a03;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    min-width: 1.25rem;
    text-align: center;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.9rem 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(2, 6, 23, 0.3);
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: linear-gradient(135deg, #10b981, #0d9488);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.7rem;
}

.user-name {
    color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.25;
}

.user-role {
    color: #94a3b8;
    font-size: 0.68rem;
}

.logout-btn {
    background: transparent;
    border: 0;
    color: #94a3b8;
    padding: 0.4rem;
    border-radius: 0.45rem;
    font-size: 1rem;
    line-height: 1;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.18);
    color: #fecaca;
}

/* ------------------------------------------------------------
   Top bar & main
   ------------------------------------------------------------ */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1.25rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

@media (min-width: 1024px) {
    .app-topbar {
        padding: 0.95rem 1.8rem;
    }
}

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.01em;
}

.page-subtitle {
    font-size: 0.76rem;
    color: var(--muted);
    margin: 0.15rem 0 0;
}

.menu-toggle {
    background: #f8fafc;
    border: 1px solid var(--line);
    color: #334155;
    width: 38px;
    height: 38px;
    border-radius: 0.6rem;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.menu-toggle:hover {
    background: #f1f5f9;
}

@media (min-width: 1024px) {
    .menu-toggle {
        display: none;
    }
}

.topbar-date {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--muted);
    background: #f8fafc;
    border: 1px solid var(--line);
    padding: 0.42rem 0.7rem;
    border-radius: 999px;
    white-space: nowrap;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding-left: 0.85rem;
    border-left: 1px solid var(--line);
}

.app-main {
    flex: 1;
    padding: 1.1rem 1rem 1.5rem;
}

@media (min-width: 768px) {
    .app-main {
        padding: 1.4rem 1.8rem 2rem;
    }
}

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.8rem;
    border-top: 1px solid var(--line);
    color: #94a3b8;
    font-size: 0.7rem;
    background: #fff;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

/* ------------------------------------------------------------
   Cards
   ------------------------------------------------------------ */
.card-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    overflow: hidden;
}

.card-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.95rem 1.15rem;
    border-bottom: 1px solid #f1f5f9;
}

.card-panel-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

.card-panel-subtitle {
    font-size: 0.72rem;
    color: var(--muted);
    margin: 0.1rem 0 0;
}

.card-panel-body {
    padding: 1.1rem 1.15rem;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    padding: 1rem 1.05rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    height: 100%;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.15;
    margin-top: 0.15rem;
}

.stat-hint {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */
.table-shell {
    width: 100%;
    overflow-x: auto;
}

.table-sarsali {
    width: 100%;
    margin: 0;
    font-size: 0.83rem;
    color: #334155;
    border-collapse: collapse;
}

.table-sarsali thead th {
    background: #f8fafc;
    color: #64748b;
    text-transform: uppercase;
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    text-align: left;
}

.table-sarsali tbody td {
    padding: 0.72rem 0.9rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.table-sarsali tbody tr:hover {
    background: #f8fafc;
}

.table-sarsali tbody tr:last-child td {
    border-bottom: 0;
}

.table-sarsali .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table-sarsali .actions {
    text-align: right;
    white-space: nowrap;
}

.cell-title {
    font-weight: 600;
    color: var(--ink);
}

.cell-sub {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* ------------------------------------------------------------
   Badges, flash messages
   ------------------------------------------------------------ */
.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-info { background: #dbeafe; color: #1e40af; }
.badge-soft-warning { background: #fef3c7; color: #92400e; }
.badge-soft-danger { background: #fee2e2; color: #991b1b; }
.badge-soft-secondary { background: #f1f5f9; color: #475569; }
.badge-soft-purple { background: #ede9fe; color: #5b21b6; }

.flash-msg {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 0.9rem;
    border-radius: 0.7rem;
    font-size: 0.82rem;
    margin-bottom: 0.9rem;
    border: 1px solid transparent;
    animation: flash-in 0.2s ease;
}

@keyframes flash-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.flash-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.flash-error,
.flash-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.flash-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.flash-close {
    background: transparent;
    border: 0;
    color: inherit;
    opacity: 0.55;
    font-size: 0.7rem;
    padding: 0.15rem;
    line-height: 1;
}

.flash-close:hover {
    opacity: 1;
}

/* ------------------------------------------------------------
   Forms & buttons
   ------------------------------------------------------------ */
.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border: 1px solid #cbd5e1;
    border-radius: 0.55rem;
    font-size: 0.83rem;
    padding: 0.5rem 0.7rem;
    color: #0f172a;
    background-color: #fff;
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-control:focus,
.form-select:focus {
    border-color: #34d399;
    box-shadow: 0 0 0 0.18rem rgba(5, 150, 105, 0.14);
}

.form-control:disabled,
.form-select:disabled {
    background: #f8fafc;
    color: #64748b;
}

.form-hint {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.3rem;
}

.form-error {
    font-size: 0.72rem;
    color: #dc2626;
    margin-top: 0.3rem;
}

.required-mark {
    color: #dc2626;
    margin-left: 0.1rem;
}

.btn-brand,
.btn-soft,
.btn-soft-danger,
.btn-outline-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 0.55rem;
    padding: 0.48rem 0.9rem;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    cursor: pointer;
    line-height: 1.4;
}

.btn-brand {
    background: var(--brand-600);
    color: #fff;
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.25);
}

.btn-brand:hover {
    background: var(--brand-700);
    color: #fff;
}

.btn-soft {
    background: #f8fafc;
    color: #334155;
    border-color: var(--line);
}

.btn-soft:hover {
    background: #f1f5f9;
    color: var(--ink);
}

.btn-soft-danger {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.btn-soft-danger:hover {
    background: #fee2e2;
    color: #991b1b;
}

.btn-outline-brand {
    background: #fff;
    color: var(--brand-700);
    border-color: #a7f3d0;
}

.btn-outline-brand:hover {
    background: var(--brand-50);
    color: var(--brand-700);
}

.btn-xs {
    padding: 0.28rem 0.55rem;
    font-size: 0.72rem;
    border-radius: 0.4rem;
}

.btn-lg-brand {
    padding: 0.65rem 1.1rem;
    font-size: 0.88rem;
}

/* ------------------------------------------------------------
   Filters, pagination, misc
   ------------------------------------------------------------ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: flex-end;
}

.filter-bar .form-control,
.filter-bar .form-select {
    min-width: 9rem;
}

.search-input-wrap {
    position: relative;
}

.search-input-wrap i {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.8rem;
    pointer-events: none;
}

.search-input-wrap .form-control {
    padding-left: 2rem;
}

.pagination .page-link {
    color: #475569;
    border-color: var(--line);
    font-size: 0.75rem;
    padding: 0.32rem 0.6rem;
}

.pagination .page-item.active .page-link {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}

.pagination .page-link:hover {
    color: var(--brand-700);
    background: var(--brand-50);
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #94a3b8;
}

.empty-state i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.6rem;
    color: #cbd5e1;
}

.empty-state p {
    margin: 0;
    font-size: 0.82rem;
}

.section-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 0.75rem;
}

.detail-label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.detail-value {
    font-size: 0.84rem;
    color: #1e293b;
    font-weight: 500;
}

.recipe-line td {
    vertical-align: middle;
}

/* ------------------------------------------------------------
   Auth screens
   ------------------------------------------------------------ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: #f8fafc;
}

.auth-hero {
    display: none;
    width: 46%;
    padding: 3.5rem;
    background:
        radial-gradient(circle at 20% 10%, rgba(16, 185, 129, 0.35), transparent 45%),
        radial-gradient(circle at 90% 90%, rgba(13, 148, 136, 0.32), transparent 40%),
        linear-gradient(160deg, #0b1220 0%, #0f172a 60%, #111c31 100%);
    color: #e2e8f0;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.auth-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(148, 163, 184, 0.12) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.35;
    pointer-events: none;
}

@media (min-width: 992px) {
    .auth-hero {
        display: flex;
    }
}

.auth-hero-content {
    position: relative;
    z-index: 1;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.auth-headline {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    color: #fff;
    letter-spacing: -0.02em;
    margin-bottom: 0.9rem;
}

.auth-copy {
    color: #94a3b8;
    font-size: 0.9rem;
    line-height: 1.7;
    max-width: 26rem;
}

.auth-feature {
    display: flex;
    gap: 0.7rem;
    margin-top: 1.1rem;
    font-size: 0.82rem;
    color: #cbd5e1;
}

.auth-feature i {
    color: #34d399;
    font-size: 0.95rem;
    margin-top: 0.1rem;
}

.auth-form-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    padding: 2rem;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

.auth-card h1 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 0.25rem;
}

.auth-card .subtext {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.demo-hint {
    margin-top: 1.25rem;
    padding: 0.7rem 0.85rem;
    border-radius: 0.6rem;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.6;
}

/* ------------------------------------------------------------
   Print (purchase order)
   ------------------------------------------------------------ */
@media print {
    .app-sidebar,
    .app-topbar,
    .app-footer,
    .page-actions,
    .no-print {
        display: none !important;
    }

    .app-content {
        margin-left: 0 !important;
    }

    .app-main {
        padding: 0 !important;
    }

    body {
        background: #fff;
    }

    .card-panel {
        border: 0;
        box-shadow: none;
    }
}
