/* ============================================================
   STOCK MANAGER PRO - GLOBAL STYLESHEET
   Design: Ledger-inspired - warm paper background, navy/teal
   accents, monospace for numbers (invoice/ledger feel)
   ============================================================ */

:root {
    --color-bg:        #F6F4EF;
    --color-surface:   #FFFFFF;
    --color-surface-2: #EFEBE2;
    --color-border:    #E0DBCE;
    --color-border-strong: #C9C2B2;

    --color-text:      #2B2A28;
    --color-text-muted:#75716A;
    --color-text-faint:#A6A199;

    --color-primary:   #1D4E4A;   /* deep teal - headers, nav */
    --color-primary-dk:#123332;
    --color-accent:    #C9622A;   /* burnt orange - CTAs, highlights */
    --color-accent-dk: #9C4A1C;

    --color-success:   #3B6D11;
    --color-success-bg:#EAF3DE;
    --color-warning:   #854F0B;
    --color-warning-bg:#FAEEDA;
    --color-danger:    #A32D2D;
    --color-danger-bg: #FCEBEB;
    --color-info:      #185FA5;
    --color-info-bg:   #E6F1FB;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body:    'Inter', -apple-system, Segoe UI, sans-serif;
    --font-mono:    'IBM Plex Mono', 'Courier New', monospace;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(43,42,40,0.06);
    --shadow-md: 0 2px 8px rgba(43,42,40,0.08);

    --sidebar-w: 248px;
    --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a { color: var(--color-info); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 0.5rem;
}
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.mono { font-family: var(--font-mono); }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--color-primary);
    color: #E8EEEC;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-brand {
    padding: 18px 20px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.sidebar-brand .logo-img-wrap {
    background: transparent;
    display: inline-flex;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 0;
    line-height: 0;
}
.sidebar-brand .logo-img {
    height: 100%;
    width: 100%;
    max-width: 100%;
    display: block;
    object-fit: contain;
}
.sidebar-brand .logo-mark {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}
.sidebar-brand .logo-sub {
    font-size: 11px;
    color: #9FBDB8;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 2px;
}

.nav-section {
    padding: 12px 12px 4px;
}
.nav-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #7FA39D;
    padding: 8px 12px 4px;
    font-weight: 600;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: #D6E5E2;
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.12s;
}
.nav-link:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--color-accent); color: #fff; }
.nav-link i { font-size: 17px; width: 18px; text-align: center; }

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 40;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--color-text-muted);
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--color-accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; font-family: var(--font-display);
}

.content {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header .eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-accent-dk);
    font-weight: 600;
    margin-bottom: 4px;
}

/* ============================================================
   CARDS / SURFACES
   ============================================================ */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--color-primary);
}
.stat-card .stat-sub {
    font-size: 12px;
    color: var(--color-text-faint);
    margin-top: 4px;
}
.stat-card.accent { border-left: 3px solid var(--color-accent); }
.stat-card.success { border-left: 3px solid var(--color-success); }
.stat-card.danger { border-left: 3px solid var(--color-danger); }
.stat-card.info { border-left: 3px solid var(--color-info); }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group.full { grid-column: 1 / -1; }
label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-muted);
}
label .req { color: var(--color-danger); }

input[type=text], input[type=email], input[type=number], input[type=password],
input[type=date], input[type=datetime-local], input[type=tel], select, textarea {
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: var(--font-body);
    background: var(--color-surface);
    color: var(--color-text);
    width: 100%;
    transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(29,78,74,0.12);
}
textarea { resize: vertical; min-height: 70px; }

fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin: 0 0 16px;
}
fieldset legend {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-primary);
    padding: 0 6px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.icon-svg { flex-shrink: 0; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { background: var(--color-surface-2); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dk); }
.btn-accent { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.btn-accent:hover { background: var(--color-accent-dk); }
.btn-danger { background: var(--color-danger-bg); border-color: var(--color-danger); color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger); color: #fff; }
.btn-success { background: var(--color-success-bg); border-color: var(--color-success); color: var(--color-success); }
.btn-success:hover { background: var(--color-success); color: #fff; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
table { width: 100%; border-collapse: collapse; background: var(--color-surface); font-size: 13px; }
table th, table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
table th {
    background: var(--color-surface-2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-text-muted);
    font-weight: 700;
    position: sticky; top: 0;
}
table tbody tr:hover { background: #FBFAF6; }
table tbody tr:last-child td { border-bottom: none; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.num { font-family: var(--font-mono); text-align: right; }

/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }
.badge-muted { background: var(--color-surface-2); color: var(--color-text-muted); }

/* ============================================================
   ALERTS / FLASH
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 13.5px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(59,109,17,0.2); }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: rgba(163,45,45,0.2); }
.alert-info { background: var(--color-info-bg); color: var(--color-info); border-color: rgba(24,95,165,0.2); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: rgba(133,79,11,0.2); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(30,30,28,0.45);
    display: none;
    align-items: center; justify-content: center;
    z-index: 100;
}
.modal-backdrop.show { display: flex; }
.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}
.modal-lg { max-width: 760px; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}
.modal-header h2 { margin: 0; }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-end { display: flex; justify-content: flex-end; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-sm { font-size: 12px; }
.w-100 { width: 100%; }
.divider { border-top: 1px solid var(--color-border); margin: 16px 0; }
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-faint);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: 0.5; }

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    background-image: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-dk) 100%);
}
.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
}
.login-card .logo-mark {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--color-primary);
    text-align: center;
}
.login-logo-img {
    display: block;
    margin: 0 auto 8px;
    height: 48px;
    width: auto;
}
.login-card .logo-sub {
    text-align: center;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-text-faint);
    margin-bottom: 28px;
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.show { transform: translateX(0); }
    .main { margin-left: 0; }
    .mobile-toggle { display: inline-flex !important; }
}
.mobile-toggle { display: none; }

/* Print styles for invoice/quotation documents */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .content { padding: 0; }
}
