@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --black: #111111;
    --accent: #c41e3a;
    --accent-soft: rgba(196, 30, 58, 0.08);
    --accent-muted: rgba(196, 30, 58, 0.15);
    --success-soft: rgba(22, 101, 52, 0.08);
    --success: #166534;
    --radius: 10px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 2px 10px rgba(0,0,0,.06);
    --nav-h: 56px;
    --nav-float: 62px;
    --header-h: 52px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--gray-100);
    color: var(--black);
    line-height: 1.5;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* App Shell */
.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    background: var(--gray-50);
    position: relative;
}

@media (min-width: 481px) {
    body { background: var(--gray-200); }
    .app-shell { min-height: calc(100dvh - 24px); margin: 12px auto; border-radius: 12px; overflow: hidden; border: 1px solid var(--gray-200); }
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--black);
    color: var(--white);
    height: var(--header-h);
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 100%;
}

.brand { display: flex; align-items: center; gap: 8px; }

.brand-logo {
    width: 28px; height: 28px;
    background: rgba(255,255,255,.1);
    color: var(--white);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0;
}
.brand-logo-icon { color: var(--white); opacity: .9; }

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.brand-sub { font-size: 10px; opacity: .5; }

.header-action {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 7px;
    opacity: .65;
    transition: opacity .15s;
}
.header-action:hover { opacity: 1; }

/* Main */
.app-main {
    padding: 12px;
    padding-bottom: calc(var(--nav-float) + var(--safe-bottom) + 12px);
    min-height: calc(100dvh - var(--header-h));
}

.page-header { margin-bottom: 14px; }
.page-header h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.page-header p { font-size: 12px; color: var(--gray-600); margin-top: 2px; }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    padding: 6px 10px calc(6px + var(--safe-bottom));
    z-index: 100;
    pointer-events: none;
}

.bottom-nav-inner {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 4px;
    pointer-events: auto;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 9px;
    color: var(--gray-500);
    transition: color .15s, background .15s;
    padding: 6px 2px;
    border-radius: 10px;
    min-height: 44px;
}

.nav-icon-wrap {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background .15s;
}

.nav-item.active {
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-soft);
}

.nav-item.active .nav-icon-wrap {
    background: transparent;
    box-shadow: none;
}

.nav-item:active { transform: scale(.96); }
.nav-item svg { stroke: currentColor; }

/* Dashboard sections */
.dash-section {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--gray-200);
}
.dash-section-last { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

.section-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.section-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.section-label-row .section-label { margin-bottom: 0; }

.stats-grid-compact { margin-bottom: 8px; }
.stat-card-highlight {
    border: 1px solid var(--gray-200);
    background: var(--white);
}
.banner-compact { margin-bottom: 0; }

.doc-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.doc-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    min-height: 96px;
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    transition: border-color .15s, background .15s;
    text-align: center;
}
.doc-type-btn:active { background: var(--gray-50); }
.doc-type-btn:hover { border-color: var(--gray-300); }

.doc-type-btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--gray-100);
    color: var(--gray-700);
}

.doc-type-btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    width: 100%;
}
.doc-type-btn-text strong {
    font-size: 11px;
    font-weight: 600;
    color: var(--black);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.doc-type-btn-text small {
    font-size: 10px;
    color: var(--gray-500);
}

.doc-type-btn-arrow { display: none; }

.dash-section-first { padding-top: 0; }

.dash-search {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
}
.dash-search .form-group { margin-bottom: 10px; }
.dash-search .form-group:last-of-type { margin-bottom: 0; }
.dash-search-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.dash-search-list { margin-bottom: 14px; }

.search-results-block {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}
.search-results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--gray-600);
}
.havale-cards-compact { gap: 6px; }
.empty-state-compact { padding: 20px 12px; }

.form-row-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
@media (min-width: 520px) {
    .form-row-grid { grid-template-columns: repeat(3, 1fr); }
}
.form-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    margin: 0 0 8px;
    text-transform: none;
}
.employee-list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.employee-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
}
@media (min-width: 520px) {
    .employee-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}
.employee-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.employee-info strong { font-size: 13px; }
.employee-user { font-size: 11px; color: var(--gray-500); direction: ltr; text-align: right; }
.employee-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    align-items: flex-start;
}
.inline-form { display: inline; }
.employee-add-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-100); }
.employee-name-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.employee-name-input {
    flex: 1;
    min-width: 120px;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: #fff;
}
.user-password-details { position: relative; }
.user-password-details summary {
    list-style: none;
    cursor: pointer;
}
.user-password-details summary::-webkit-details-marker { display: none; }
.user-password-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}
.user-password-form input[type="password"] {
    flex: 1;
    min-width: 120px;
    padding: 6px 8px;
    font-size: 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}


.doc-type-btn-1 .doc-type-btn-icon,
.doc-type-btn-2 .doc-type-btn-icon,
.doc-type-btn-3 .doc-type-btn-icon,
.doc-type-btn-4 .doc-type-btn-icon,
.doc-type-btn-5 .doc-type-btn-icon,
.doc-type-btn-6 .doc-type-btn-icon {
    background: var(--gray-100);
    color: var(--gray-700);
}

.doc-type-btn-1,
.doc-type-btn-2,
.doc-type-btn-3,
.doc-type-btn-4,
.doc-type-btn-5,
.doc-type-btn-6 { border-right: none; }
.doc-type-btn-1 .doc-type-btn-icon { color: var(--accent); background: var(--accent-soft); }

.card-flush { margin-bottom: 0; }

.list-item-rich { gap: 10px; }
.doc-type-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--gray-100);
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrap-sm { height: 150px; }
.dash-section-charts { margin-bottom: 18px; }
.chart-grid-duo {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}
.chart-card-wide { margin-bottom: 0; }
.chart-wrap-pie { height: 168px; }
.chart-wrap-bar { height: 168px; }
.chart-wrap-line { height: 140px; }
.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    font-size: 11px;
    color: var(--gray-500);
    text-align: center;
    padding: 12px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--gray-200);
}

.stat-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon.dark { background: var(--gray-800); color: var(--white); }
.stat-icon.gray { background: var(--gray-200); color: var(--gray-700); }
.stat-icon.light { background: var(--accent-soft); color: var(--accent); }
.stat-icon.accent { background: var(--accent-soft); color: var(--accent); }

.stat-value { display: block; font-size: 17px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.stat-label { display: block; font-size: 10px; color: var(--gray-500); }

/* Banner */
.banner {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 12px;
}
.banner-info {
    background: var(--success-soft);
    border: 1px solid rgba(22, 101, 52, 0.12);
    color: #166534;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    background: var(--gray-50);
}
.card-header h3 { font-size: 13px; font-weight: 600; }

.link-sm { font-size: 11px; color: var(--gray-600); font-weight: 500; display: inline-block; }
.link-sm:hover { color: var(--accent); }

.list-item-icon { flex-shrink: 0; }
.doc-type-btn-icon svg { width: 18px; height: 18px; }
.doc-type-btn-arrow svg { display: none; }
.stat-icon svg { width: 16px; height: 16px; }
.search-icon { width: 16px; height: 16px; }

/* Charts */
.chart-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 0; }
.chart-wrap { position: relative; height: 180px; padding: 4px 8px 8px; }
.chart-card { margin-bottom: 0; }
.chart-card .card-header { padding: 8px 10px; }
.chart-card .card-header h3 { font-size: 12px; }

/* List */
.list-group { padding: 0; }
.list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    transition: background .12s;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--gray-50); }

.list-title { display: block; font-weight: 600; font-size: 13px; }
.list-sub { display: block; font-size: 11px; color: var(--gray-500); margin-top: 1px; }
.list-item-meta { text-align: left; }
.list-date { display: block; font-size: 10px; color: var(--gray-500); margin-top: 3px; }
.list-meta {
    display: block;
    font-size: 10px;
    color: var(--gray-500);
    margin-top: 2px;
}

.badge {
    display: inline-block;
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 500;
}
.badge-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

/* Search */
.search-bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    margin-bottom: 12px;
    border: 1px solid var(--gray-200);
}
.search-bar svg { color: var(--gray-400); flex-shrink: 0; }
.search-bar input {
    flex: 1; border: none; outline: none;
    padding: 10px 0;
    font-family: inherit; font-size: 13px;
    background: transparent;
}

/* Havale Cards */
.havale-cards { display: flex; flex-direction: column; gap: 8px; }

.havale-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid var(--gray-200);
    transition: border-color .12s, background .12s;
    display: block;
}
.havale-card:hover { border-color: var(--gray-300); }
.havale-card:active { background: var(--gray-50); }

.type-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.type-filters::-webkit-scrollbar { display: none; }

.type-chip {
    flex-shrink: 0;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    background: var(--white);
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
    transition: all .12s;
}
.type-chip.active {
    background: var(--black);
    border-color: var(--black);
    color: var(--white);
}

.doc-type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--gray-100);
    color: var(--gray-700);
}
.doc-type-badge-lg {
    font-size: 11px;
    padding: 4px 10px;
    margin-bottom: 6px;
}

.havale-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 8px; }
.havale-card-meta { display: flex; flex-direction: column; gap: 3px; }
.havale-card-meta.meta-right { align-items: flex-end; text-align: left; }
.meta-label { font-size: 9px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.04em; }

.header-notify { position: relative; border: none; background: transparent; cursor: pointer; padding: 6px; }
.notify-badge {
    position: absolute; top: 0; left: 0;
    min-width: 16px; height: 16px; padding: 0 4px;
    font-size: 9px; font-weight: 700; line-height: 16px; text-align: center;
    background: var(--accent, #c41e3a); color: #fff; border-radius: 999px;
}
.havale-toast {
    position: fixed; top: 72px; left: 50%; transform: translateX(-50%) translateY(-120%);
    z-index: 9999; width: min(92vw, 360px);
    background: #111; color: #fff; border-radius: 12px; padding: 12px 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    opacity: 0; pointer-events: none;
    transition: transform 0.35s ease, opacity 0.35s ease;
}
.havale-toast.toast-show {
    transform: translateX(-50%) translateY(0);
    opacity: 1; pointer-events: auto;
}
.havale-toast .toast-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.havale-toast .toast-body { font-size: 12px; color: #ddd; line-height: 1.5; }

.havale-no { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.havale-date { font-size: 11px; color: var(--gray-500); }
.havale-customer { font-weight: 500; font-size: 12px; margin-bottom: 2px; color: var(--gray-800); }
.havale-phone { font-size: 11px; color: var(--gray-500); direction: ltr; text-align: right; }
.havale-desc { font-size: 11px; color: var(--gray-500); margin-top: 4px; }
.havale-card-footer { display: flex; gap: 6px; margin-top: 8px; }

/* Icons — minimal use */
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

.page-header h2,
.card-header h3,
.detail-card h3,
.section-title h3 {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Hide decorative/redundant icons */
.page-title-icon,
.page-sub-icon,
.section-icon,
.link-icon,
.card-icon,
.field-icon,
.inline-icon,
.chip-icon,
.badge-icon { display: none !important; }

.section-label {
    display: block;
}
.page-header p { display: block; }

.section-icon,
.page-sub-icon { display: none !important; }

.detail-label {
    display: inline-block;
}
.item-field > span:first-child {
    display: block;
    font-size: 10px;
    color: var(--gray-500);
    margin-bottom: 2px;
}
.doc-type-badge-icon { display: inline-block; }
.type-chip { display: inline-block; }
.havale-no,
.havale-customer,
.havale-phone,
.havale-desc,
.havale-date { display: block; }
.badge { display: inline-block; }
.list-title,
.list-meta,
.list-date { display: block; }
.item-card-head { display: block; font-size: 11px; font-weight: 600; color: var(--gray-600); margin-bottom: 8px; }
.doc-type-btn-text small { display: block; }
.banner { gap: 0; }
.empty-state span { display: block; }
.form-group label,
.settings-block label { display: block; }
.btn-copy,
.btn-primary { gap: 0; }

.page-back-bar { margin-bottom: 10px; }

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    box-shadow: none;
}
.back-btn:hover { color: var(--black); border: none; box-shadow: none; }
.back-btn:active { transform: none; opacity: .7; }
.back-btn svg { color: var(--gray-500); flex-shrink: 0; width: 16px; height: 16px; }

.detail-header {
    margin-bottom: 12px;
    padding-bottom: 0;
    border-bottom: none;
}

.detail-card { padding: 12px; }
.detail-card h3 { font-size: 13px; margin-bottom: 10px; font-weight: 600; }

.detail-rows { display: flex; flex-direction: column; gap: 8px; }
.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-100);
}
.detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.detail-label { color: var(--gray-500); flex-shrink: 0; font-size: 11px; }
.detail-value { text-align: left; font-weight: 500; font-size: 12px; }
.detail-row-desc {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.detail-row-desc .detail-value {
    text-align: right;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.section-title { margin: 14px 0 8px; }
.section-title h3 { font-size: 13px; font-weight: 600; }

.item-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 6px;
    border: 1px solid var(--gray-200);
}
.item-top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.item-code { font-size: 12px; color: var(--gray-600); font-family: monospace; direction: ltr; }
.item-qty { font-weight: 700; font-size: 14px; }
.item-name { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.item-meta {
    display: flex; flex-wrap: wrap; gap: 10px;
    font-size: 11px; color: var(--gray-600);
}
.item-meta span { display: inline-flex; align-items: center; gap: 4px; }

/* Warehouse */
.warehouse-grid { display: flex; flex-direction: column; gap: 10px; }

.warehouse-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 14px;
}

.wh-icon {
    width: 48px; height: 48px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.wh-info { flex: 1; }
.wh-name { display: block; font-weight: 600; font-size: 14px; }
.wh-code { display: block; font-size: 11px; color: var(--gray-500); direction: ltr; }

.wh-stats {
    display: flex; flex-direction: column; gap: 2px;
    text-align: left; font-size: 11px; color: var(--gray-600);
}
.wh-stats strong { color: var(--black); }

/* Empty */
.empty-state {
    text-align: center;
    padding: 28px 16px;
    color: var(--gray-500);
}
.empty-state svg,
.empty-icon { width: 32px !important; height: 32px !important; margin-bottom: 8px; opacity: .25; }
.empty-state p { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.empty-state span { font-size: 11px; color: var(--gray-500); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px; font-weight: 600;
    border: none; cursor: pointer;
    transition: opacity .15s;
}
.btn:active { opacity: .85; }
.btn-primary {
    background: var(--black);
    color: var(--white);
}
.btn-primary:hover { background: #222; }
.btn-outline { background: var(--white); color: var(--black); border: 1px solid var(--gray-300); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 5px; color: var(--gray-600); }
.form-group input {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px;
    background: var(--white);
    transition: border-color .15s;
}
.form-group input:focus { outline: none; border-color: var(--gray-400); box-shadow: none; }

/* Alerts */
.alert {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 12px;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Settings */
.settings-block { padding: 12px; }
.settings-block label { display: block; font-size: 11px; color: var(--gray-500); margin-bottom: 4px; }
.settings-form { padding: 12px; }
.text-muted { font-size: 12px; color: var(--gray-600); line-height: 1.6; }
.mt-2 { margin-top: 8px; }

.copy-field {
    display: flex; align-items: center; gap: 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.copy-field code {
    flex: 1; font-size: 11px; word-break: break-all;
    direction: ltr; text-align: left;
    font-family: 'Courier New', monospace;
}
.btn-copy {
    flex-shrink: 0;
    padding: 5px 10px;
    background: var(--gray-800);
    color: var(--white);
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
}

/* Login */
.login-body, .install-body {
    background: var(--gray-100);
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}

.login-wrap, .install-wrap { width: 100%; max-width: 360px; }

.login-card, .install-card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px 20px;
    border: 1px solid var(--gray-200);
    text-align: center;
}

.login-logo,
.install-logo {
    width: 40px; height: 40px;
    background: var(--black);
    color: var(--white);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0;
    margin: 0 auto 12px;
    box-shadow: none;
}
.login-logo-icon,
.install-logo-icon { color: var(--white) !important; }

.login-card h1, .install-card h1 { font-size: 17px; font-weight: 600; display: block; }
.login-sub, .install-sub { font-size: 12px; color: var(--gray-500); margin-bottom: 20px; display: block; }
.install-form h3 {
    font-size: 13px; font-weight: 600;
    margin: 16px 0 10px;
    padding-bottom: 6px;
    display: block;
    border-bottom: 1px solid var(--gray-100);
    text-align: right;
}

.login-form, .install-form { text-align: right; }

.install-steps {
    display: flex; align-items: center; justify-content: center;
    gap: 0; margin-bottom: 20px;
}
.install-steps span {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-600);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
}
.install-steps span.done { background: var(--black); color: var(--white); }
.install-steps .line { width: 32px; height: 1px; background: var(--gray-200); }

.search-bar:focus-within { border-color: var(--gray-400); box-shadow: none; }

.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; margin-top: 12px;
}
.page-info { font-size: 12px; color: var(--gray-600); }

.detail-ltr { direction: ltr; unicode-bidi: plaintext; text-align: left; display: inline-block; }

.item-card-structured { padding: 0; overflow: hidden; border: 1px solid var(--gray-200); }
.item-card-structured .item-card-head {
    background: var(--gray-50);
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-600);
    margin-bottom: 0;
}
.item-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    padding: 12px;
}
.item-field { display: flex; flex-direction: column; gap: 2px; }
.item-field-wide { grid-column: 1 / -1; }
.item-field span { font-size: 10px; color: var(--gray-500); }
.item-field strong { font-size: 12px; font-weight: 600; line-height: 1.45; }

@media (min-width: 481px) {
    .item-fields { grid-template-columns: repeat(3, 1fr); }
    .item-field-wide { grid-column: span 2; }
}

/* Preview hub */
.preview-hub-body { background: var(--gray-100); min-height: 100dvh; padding: 20px 12px; }
.preview-hub { max-width: 480px; margin: 0 auto; }
.preview-hub-header { text-align: center; margin-bottom: 20px; }
.preview-hub-header h1 { font-size: 17px; margin: 10px 0 4px; font-weight: 600; }
.preview-hub-header p { font-size: 12px; color: var(--gray-500); }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview-link {
    background: var(--white);
    border-radius: var(--radius);
    padding: 18px 14px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform .15s, box-shadow .15s;
    border: 1px solid rgba(0,0,0,0.04);
}
.preview-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.preview-link-icon {
    width: 44px; height: 44px;
    margin: 0 auto 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.preview-link span { display: block; font-size: 13px; font-weight: 600; }
.preview-link small { display: block; font-size: 10px; color: var(--gray-500); margin-top: 4px; }
.preview-badge-top {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 10px;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 8px;
}
@media (min-width: 481px) { .preview-grid { grid-template-columns: repeat(3, 1fr); } }

.code-block {
    display: block;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-size: 11px;
    direction: ltr;
    text-align: left;
    word-break: break-all;
    margin: 8px 0;
}

.install-info { text-align: right; margin-bottom: 20px; font-size: 13px; }
.install-warn { font-size: 12px; color: #b45309; margin-top: 12px; }

@media (min-width: 481px) {
    .chart-wrap-pie, .chart-wrap-bar { height: 190px; }
    .chart-wrap-line { height: 160px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .app-main { padding: 20px 24px; padding-bottom: calc(var(--nav-float) + var(--safe-bottom) + 20px); }
}

/* Havale detail — delivery, verification, modal */
.detail-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.delivery-section-card {
    border: 1px solid var(--accent-muted);
    box-shadow: var(--shadow-lg);
    margin-bottom: 12px;
}
.delivery-section-card > h3 {
    color: var(--accent);
}
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}
.delivery-type-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 12px;
}
@media (min-width: 400px) {
    .delivery-type-grid { grid-template-columns: repeat(2, 1fr); }
}
.delivery-type-btn {
    border: 1px solid var(--gray-200);
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-800);
    cursor: pointer;
    text-align: right;
    transition: border-color .15s, background .15s;
}
.delivery-type-btn.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}
.delivery-panel-block { padding-top: 4px; }
.delivery-time-row { margin: 10px 0; }
.badge-success {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--success);
    background: var(--success-soft);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}
.badge-icon { vertical-align: middle; }
.waiting-parts-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.waiting-part-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    cursor: pointer;
}
.waiting-part-row input { margin-top: 3px; flex-shrink: 0; }
.waiting-part-label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; min-width: 0; }
.waiting-part-label span { color: var(--gray-600); font-size: 11px; }
.barnameh-upload-actions { margin: 10px 0; }
.barnameh-upload-btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.barnameh-upload-btn .btn-icon { display: inline-flex; }
.barnameh-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}
.barnameh-thumb {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--gray-200);
    aspect-ratio: 1;
}
.barnameh-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.barnameh-delete {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.item-field-code .item-code-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.item-image-search {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-700);
    flex-shrink: 0;
}
.item-image-search:hover { border-color: var(--accent); color: var(--accent); }
.stock-verify-block {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--gray-200);
}
.stock-verify-title { font-size: 11px; font-weight: 600; color: var(--gray-600); margin-bottom: 8px; }
.stock-verify-actions { display: flex; flex-direction: column; gap: 8px; }
.stock-manual-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.stock-manual-input {
    flex: 1;
    min-width: 100px;
    padding: 7px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
}
.item-card.item-verified { border-color: rgba(22, 101, 52, 0.35); background: var(--success-soft); }
.item-card.item-manual-stock { border-color: rgba(180, 83, 9, 0.35); background: rgba(180, 83, 9, 0.06); }
.item-verify-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--success);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.item-verify-badge.manual { color: #b45309; }
.item-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 12px;
    padding-bottom: calc(12px + var(--safe-bottom));
}
.modal-overlay[hidden] { display: none !important; }
.modal-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 14px; font-weight: 600; }
.modal-close {
    border: none;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    display: inline-flex;
    padding: 4px;
}
.modal-body { padding: 14px; }
.toast-host {
    position: fixed;
    bottom: calc(var(--nav-float) + var(--safe-bottom) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: min(92vw, 360px);
    pointer-events: none;
}
.toast {
    background: var(--black);
    color: var(--white);
    font-size: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 1;
    transition: opacity .3s;
}
.toast-error { background: #991b1b; }
.toast-success { background: var(--success); }
.toast-hide { opacity: 0; }
.detail-rows.compact .detail-row { padding: 6px 0; }
.btn-icon { display: inline-flex; vertical-align: middle; margin-left: 4px; }
