:root {
    --portal-bg: #f4f7fb;
    --portal-card: #ffffff;
    --portal-sidebar: #102f4c;
    --portal-sidebar-soft: #174366;
    --portal-primary: #2563eb;
    --portal-primary-dark: #1d4ed8;
    --portal-text: #172033;
    --portal-muted: #64748b;
    --portal-border: #e2e8f0;
    --portal-danger: #dc2626;
    --portal-success: #15803d;
    --portal-warning: #a16207;
    --portal-radius: 16px;
    --portal-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}


@font-face {
    font-family: 'AzarMehr';
    font-style: normal;
    font-weight: 300;
    font-display: auto;
    src: url('../style/font/300-AzarMehr-FD-Light-1.woff2') format('woff2'), url('../style/font/300-AzarMehr-FD-Light.ttf') format('truetype');
}

@font-face {
    font-family: 'AzarMehr';
    font-style: normal;
    font-weight: 400;
    font-display: auto;
    src: url('../style/font/400-AzarMehr-FD-Regular-1.woff2') format('woff2'), url('../style/font/400-AzarMehr-FD-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'AzarMehr';
    font-style: normal;
    font-weight: 500;
    font-display: auto;
    src: url('../style/font/500-AzarMehr-FD-Medium-1.woff2') format('woff2'), url('../style/font/500-AzarMehr-FD-Medium.ttf') format('truetype');
}

@font-face {
    font-family: 'AzarMehr';
    font-style: normal;
    font-weight: 600;
    font-display: auto;
    src: url('../style/font/600-AzarMehr-FD-SemiBold-1.woff2') format('woff2'), url('../style/font/600-AzarMehr-FD-SemiBold.ttf') format('truetype');
}

@font-face {
    font-family: 'AzarMehr';
    font-style: normal;
    font-weight: 700;
    font-display: auto;
    src: url('../style/font/700-AzarMehr-FD-Bold-1.woff2') format('woff2'), url('../style/font/700-AzarMehr-FD-Bold.ttf') format('truetype');
}

@font-face {
    font-family: 'AzarMehr';
    font-style: normal;
    font-weight: 800;
    font-display: auto;
    src: url('../style/font/800-AzarMehr-FD-ExtraBold-1.woff2') format('woff2'), url('../style/font/800-AzarMehr-FD-ExtraBold.ttf') format('truetype');
}
 
* {
    box-sizing: border-box;
    font-family: 'AzarMehr' !important;
}
html { min-height: 100%; }
body {
    min-height: 100%;
    margin: 0;
    background: var(--portal-bg);
    color: var(--portal-text);
    font-family: Tahoma, "Segoe UI", sans-serif;
    font-size: 14px;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.portal-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100vh;
}

.portal-sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--portal-sidebar), #0c263f);
    color: #fff;
    padding: 22px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: -8px 0 30px rgba(15, 23, 42, .08);
}

.portal-brand-wrap { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 8px; }
.portal-brand { color: #fff; text-decoration: none; font-size: 28px; font-weight: 900; letter-spacing: -.5px; }
.portal-role-badge { background: rgba(255,255,255,.12); color: #dbeafe; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 4px 8px; font-size: 11px; white-space: nowrap; }

.portal-nav { display: flex; flex-direction: column; gap: 4px; }
.portal-nav-title { margin: 13px 10px 5px; color: #8fb5d5; font-size: 11px; font-weight: 800; }
.portal-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 40px;
    color: #dcecff;
    text-decoration: none;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: .18s ease;
}
.portal-nav a small { color: #9ec3df; font-size: 10px; }
.portal-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.portal-nav a.active { background: #fff; color: #123451; font-weight: 800; box-shadow: 0 7px 18px rgba(0,0,0,.12); }
.portal-nav a.active small { color: #64748b; }

.logout-form { margin-top: auto; }
.logout-form button {
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(255,255,255,.28);
    background: rgba(255,255,255,.03);
    color: #fff;
    border-radius: 11px;
    cursor: pointer;
    transition: .18s ease;
}
.logout-form button:hover { background: rgba(255,255,255,.1); }

.portal-main { min-width: 0; padding: 22px 26px 40px; }
.portal-topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.portal-topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.portal-topbar h1 { margin: 0 0 4px; font-size: clamp(20px, 2vw, 27px); line-height: 1.4; }
.portal-topbar span { color: var(--portal-muted); font-size: 12px; }
.portal-site-link { color: var(--portal-primary); text-decoration: none; white-space: nowrap; font-weight: 700; }
.portal-menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--portal-border); border-radius: 10px; background: #fff; color: var(--portal-text); cursor: pointer; }

.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.portal-card {
    background: var(--portal-card);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 18px;
    box-shadow: var(--portal-shadow);
}
.portal-card.compact { padding: 14px 16px; }
.portal-card h2, .portal-card h3 { margin: 0 0 10px; }
.portal-card h2 { font-size: 19px; }
.portal-card h3 { font-size: 14px; color: #344155; }
.portal-card p:last-child { margin-bottom: 0; }

.metric-card { min-height: 112px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 70px; height: 70px; left: -25px; bottom: -28px; border-radius: 50%; background: rgba(37,99,235,.07); }
.metric { font-size: 27px; line-height: 1.2; font-weight: 900; color: #0f5b94; letter-spacing: -.7px; }
.metric-label { display: block; margin-top: 5px; color: var(--portal-muted); font-size: 11px; }

.section-stack { display: grid; gap: 14px; margin-top: 14px; }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-header h2 { margin: 0 0 4px; }
.section-header p { margin: 0; }
.muted { color: var(--portal-muted); }
.text-success { color: var(--portal-success); }
.text-danger { color: var(--portal-danger); }
.text-warning { color: var(--portal-warning); }

.alert { padding: 11px 14px; border-radius: 11px; margin-bottom: 14px; border: 1px solid transparent; }
.alert.success { background: #ecfdf3; color: #166534; border-color: #bbf7d0; }
.alert.error { background: #fff1f2; color: #9f1239; border-color: #fecdd3; }
.alert.info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 14px;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    transition: .16s ease;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--portal-primary); color: #fff; }
.btn.primary:hover { background: var(--portal-primary-dark); }
.btn.secondary { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.btn.secondary:hover { background: #e2e8f0; }
.btn.danger { background: var(--portal-danger); color: #fff; }
.btn.ghost { background: #fff; color: var(--portal-primary); border-color: #bfdbfe; }
.btn.small { min-height: 32px; padding: 5px 9px; border-radius: 8px; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.filter-card { padding: 14px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); align-items: end; gap: 10px; }
.filter-grid.wide { grid-template-columns: 1.4fr repeat(4, minmax(140px, 1fr)) auto; }
.filter-actions { display: flex; align-items: end; gap: 7px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { color: #334155; font-weight: 700; font-size: 12px; }
.field input, .field select, .field textarea, .control {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 8px 11px;
    font: inherit;
    color: var(--portal-text);
    background: #fff;
    outline: 0;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.8; }
.field input:focus, .field select:focus, .field textarea:focus, .control:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.field input[readonly] { background: #f8fafc; color: #64748b; }
.validation { color: #b91c1c; font-size: 11px; }
.validation-summary-errors { color: #991b1b; background: #fff1f2; border: 1px solid #fecdd3; padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.checkbox-field input { width: 18px; height: 18px; }

.table-wrap { width: 100%; overflow: auto; border: 1px solid #edf1f5; border-radius: 12px; }
.portal-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; }
.portal-table th, .portal-table td { padding: 10px 11px; border-bottom: 1px solid #edf1f5; text-align: right; white-space: nowrap; vertical-align: middle; }
.portal-table th { position: sticky; top: 0; z-index: 1; background: #f8fafc; color: #475569; font-size: 11px; font-weight: 800; }
.portal-table tbody tr:last-child td { border-bottom: 0; }
.portal-table tbody tr:hover td { background: #fbfdff; }
.table-title { font-weight: 800; color: #1e293b; }
.table-subtitle { display: block; margin-top: 3px; color: var(--portal-muted); font-size: 11px; }
.money { direction: ltr; display: inline-block; font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; background: #e2e8f0; color: #475569; font-size: 11px; font-weight: 700; }
.badge.success { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.pagination-links { display: flex; gap: 6px; }
.pagination a, .pagination span.page-current { min-width: 36px; min-height: 34px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: 8px; border: 1px solid var(--portal-border); background: #fff; }
.pagination span.page-current { background: var(--portal-primary); color: #fff; border-color: var(--portal-primary); }

.empty-state { text-align: center; padding: 34px; color: var(--portal-muted); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.quick-action { display: block; text-decoration: none; background: #f8fafc; border: 1px solid var(--portal-border); border-radius: 12px; padding: 12px; transition: .16s ease; }
.quick-action:hover { border-color: #93c5fd; background: #eff6ff; }
.quick-action strong { display: block; margin-bottom: 4px; }
.quick-action span { color: var(--portal-muted); font-size: 11px; }

.sms-panel { background: linear-gradient(135deg, #eff6ff, #f8fbff); border: 1px solid #bfdbfe; border-radius: 13px; padding: 12px; }
.sms-form { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(260px, 2fr) auto; gap: 8px; align-items: end; }
.sms-form textarea { min-height: 42px; max-height: 100px; }
details.inline-details summary { color: var(--portal-primary); cursor: pointer; font-weight: 700; list-style: none; }
details.inline-details summary::-webkit-details-marker { display: none; }
details.inline-details[open] { min-width: 360px; }
details.inline-details .sms-panel { margin-top: 8px; }

.readonly-note { display: flex; align-items: center; gap: 8px; background: #fffbeb; color: #854d0e; border: 1px solid #fde68a; border-radius: 10px; padding: 9px 12px; font-size: 12px; }
.terms-content { white-space: pre-wrap; line-height: 2; background: #f8fafc; padding: 16px; border-radius: 12px; }

.seller-profile-strip { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.seller-profile-strip h2 { margin: 0 0 5px; }
.seller-profile-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.seller-dashboard-columns { display: grid; grid-template-columns: 1.25fr .75fr; gap: 14px; margin-top: 14px; }

/* Jalali date picker */
.seller-period-card { position: relative; overflow: visible; }
.seller-period-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.seller-period-heading h2 { margin: 0 0 5px; }
.seller-period-heading p { margin: 0; }
.seller-period-form { display: grid; grid-template-columns: minmax(190px,1fr) minmax(190px,1fr) auto; align-items: end; gap: 10px; position: relative; }
.jalali-field { display: flex; flex-direction: column; gap: 6px; position: relative; min-width: 0; }
.jalali-field > label { font-weight: 700; color: #334155; font-size: 12px; }
.jalali-input-wrap { display: flex; align-items: stretch; min-height: 42px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; overflow: hidden; transition: border-color .18s ease, box-shadow .18s ease; }
.jalali-input-wrap:focus-within { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.jalali-display { width: 100%; min-width: 0; border: 0 !important; outline: 0; background: transparent; padding: 0 11px !important; font: inherit; text-align: center; direction: ltr; color: #0f172a; cursor: pointer; }
.jalali-display::placeholder { color: #94a3b8; }
.jalali-trigger { width: 42px; flex: 0 0 42px; border: 0; border-right: 1px solid #e2e8f0; background: #f8fafc; cursor: pointer; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }
.jalali-trigger:hover { background: #eff6ff; }
.seller-period-submit { height: 42px; min-width: 110px; }
.seller-period-error { grid-column: 1 / -1; background: #fee2e2; color: #991b1b; border-radius: 10px; padding: 9px 11px; font-size: 12px; }
.seller-metrics-grid, .seller-profile-card { margin-top: 14px; }
.jalali-calendar { position: absolute; z-index: 1000; top: calc(100% + 8px); right: 0; width: min(330px, calc(100vw - 40px)); background: #fff; border: 1px solid #dbe2ea; border-radius: 15px; box-shadow: 0 20px 45px rgba(15,23,42,.18); padding: 13px; direction: rtl; user-select: none; }
.jalali-calendar[hidden] { display: none; }
.jalali-calendar-header { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 7px; margin-bottom: 9px; }
.jalali-calendar-title { text-align: center; font-weight: 800; color: #0f172a; }
.jalali-calendar-nav { width: 38px; height: 38px; border: 0; border-radius: 9px; background: #f1f5f9; color: #1e293b; cursor: pointer; font-size: 21px; }
.jalali-calendar-nav:hover { background: #dbeafe; color: #1d4ed8; }
.jalali-weekdays, .jalali-days { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 3px; }
.jalali-weekdays span { display: flex; align-items: center; justify-content: center; height: 28px; color: #64748b; font-size: 11px; font-weight: 700; }
.jalali-day { height: 36px; border: 0; border-radius: 8px; background: transparent; color: #1e293b; cursor: pointer; font: inherit; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.jalali-day:hover { background: #eff6ff; color: #1d4ed8; }
.jalali-day.is-outside { color: #a8b1bf; }
.jalali-day.is-today { box-shadow: inset 0 0 0 1px #60a5fa; color: #1d4ed8; font-weight: 800; }
.jalali-day.is-selected { background: #2563eb; color: #fff; font-weight: 800; box-shadow: none; }
.jalali-calendar-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid #e2e8f0; margin-top: 9px; padding-top: 9px; }
.jalali-calendar-action { border: 0; background: transparent; color: #2563eb; font: inherit; font-weight: 700; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.jalali-calendar-action:hover { background: #eff6ff; }
.jalali-calendar-hint { font-size: 10px; color: #94a3b8; }

@media (max-width: 1150px) {
    .filter-grid.wide { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
    .seller-dashboard-columns { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
    .portal-shell { display: block; }
    .portal-sidebar { position: fixed; top: 0; right: 0; width: 260px; transform: translateX(110%); transition: transform .2s ease; }
    .portal-shell.sidebar-open .portal-sidebar { transform: translateX(0); }
    .portal-shell.sidebar-open::after { content: ""; position: fixed; inset: 0; z-index: 40; background: rgba(15,23,42,.38); }
    .portal-main { padding: 15px; }
    .portal-menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .portal-topbar { align-items: flex-start; }
    .form-grid, .split, .filter-grid, .filter-grid.wide, .sms-form, .seller-period-form { grid-template-columns: 1fr; }
    .field.full { grid-column: auto; }
    .seller-period-submit { width: 100%; }
    .seller-period-error { grid-column: auto; }
    .quick-actions { grid-template-columns: 1fr; }
    details.inline-details[open] { min-width: 280px; }
}

@media (max-width: 560px) {
    .portal-topbar { gap: 8px; }
    .portal-site-link { font-size: 11px; }
    .portal-card { padding: 14px; border-radius: 13px; }
    .portal-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .metric-card { min-height: 100px; }
    .metric { font-size: 23px; }
    .section-header, .seller-profile-strip { flex-direction: column; align-items: stretch; }
    .pagination { align-items: flex-start; flex-direction: column; }
    .jalali-calendar { position: fixed; top: 50%; right: 50%; transform: translate(50%,-50%); width: calc(100vw - 24px); max-width: 360px; }
}
