:root {
    color-scheme: light;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-soft: #eef2ff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #dbe3ef;
    --primary: #2563eb;
    --accent: #f97316;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #b45309;
    --shadow: 0 10px 28px rgba(15, 23, 42, .08);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: default;
    opacity: .65;
}

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

.top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.brand img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.top-action {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: var(--surface);
}

.app-main {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 16px 14px 94px;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 10px;
    z-index: 30;
    width: min(calc(100% - 20px), 720px);
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 6px;
    background: rgba(255, 255, 255, .97);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.bottom-nav a {
    min-height: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.bottom-nav a.active {
    background: #eff6ff;
    color: var(--primary);
}

.nav-icon {
    height: 18px;
    font-size: 18px;
    line-height: 1;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    align-items: center;
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 24px 14px;
}

.auth-card,
.hero-panel,
.details-panel,
.settings-item,
.state-panel,
.empty-state,
.inline-panel,
.item-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.auth-card {
    padding: 22px;
    box-shadow: var(--shadow);
}

.auth-logo {
    width: 58px;
    height: 58px;
    border-radius: 8px;
    display: block;
    margin-bottom: 14px;
}

.auth-card h1,
.screen h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.35;
}

.auth-card p,
.page-heading p,
.hero-panel p,
.settings-item span,
.muted {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.screen {
    display: grid;
    gap: 14px;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.hero-panel {
    display: grid;
    gap: 16px;
    padding: 18px;
    background: linear-gradient(135deg, #ffffff, #eef2ff 55%, #fff7ed);
}

.eyebrow {
    color: var(--accent) !important;
    font-weight: 800;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.quick-action {
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.quick-action strong {
    font-size: 16px;
}

.quick-action span {
    color: var(--muted);
    font-size: 13px;
}

.form {
    display: grid;
    gap: 12px;
}

.form.compact {
    margin-top: 10px;
}

.form label,
.field-block {
    display: grid;
    gap: 6px;
    color: #334155;
    font-weight: 800;
}

input,
select,
textarea,
.control {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.time-control {
    direction: ltr;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 800;
}

.button.full {
    width: 100%;
}

.button.primary {
    color: #fff;
    background: var(--primary);
}

.button.accent {
    color: #fff;
    background: var(--accent);
}

.button.secondary {
    color: var(--text);
    background: #e2e8f0;
}

.button.ghost {
    color: var(--primary);
    background: var(--surface);
    border-color: var(--line);
}

.button.danger {
    color: #fff;
    background: var(--danger);
}

.text-link {
    display: inline-flex;
    margin-top: 14px;
    color: var(--primary);
    font-weight: 800;
}

.splitter {
    display: grid;
    place-items: center;
    margin: 16px 0 8px;
    color: var(--muted);
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 700;
}

.alert.danger {
    color: #991b1b;
    background: #fee2e2;
}

.alert.success {
    color: #166534;
    background: #dcfce7;
}

.state-panel,
.empty-state {
    display: grid;
    place-items: center;
    gap: 8px;
    min-height: 128px;
    padding: 18px;
    color: var(--muted);
    text-align: center;
}

.empty-state.compact {
    min-height: auto;
    padding: 12px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #dbeafe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.item-list {
    display: grid;
    gap: 10px;
}

.item-list.compact {
    gap: 8px;
}

.item-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    color: inherit;
}

.item-card.passive {
    pointer-events: none;
}

.item-card-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.item-card h2,
.section-block h2 {
    margin: 0;
    font-size: 18px;
}

.item-card strong {
    display: block;
    font-size: 16px;
}

.item-card span,
.item-card p {
    color: var(--muted);
    margin: 2px 0 0;
}

dl {
    display: grid;
    gap: 6px;
    margin: 0;
}

dl div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

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

dd {
    margin: 0;
    text-align: left;
    overflow-wrap: anywhere;
}

.status {
    flex: 0 0 auto;
    padding: 3px 9px;
    color: var(--primary);
    background: #dbeafe;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
}

.status.success {
    color: #166534;
    background: #dcfce7;
}

.status.danger {
    color: #991b1b;
    background: #fee2e2;
}

.status.warning {
    color: var(--warning);
    background: #fef3c7;
}

.inline-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
}

.inline-panel div {
    display: grid;
    gap: 2px;
}

.inline-panel span {
    color: var(--muted);
    font-size: 13px;
}

.check-row,
.check-chip {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.check-row input,
.check-chip input {
    width: 20px;
    min-height: 20px;
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.invoice-stamp {
    max-width: 180px;
    max-height: 110px;
    object-fit: contain;
    justify-self: end;
    padding: 8px;
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: 8px;
}

.check-chip,
.chip-list.static span {
    min-height: 38px;
    padding: 7px 10px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 700;
}

.section-block {
    display: grid;
    gap: 10px;
}

.details-panel {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.timeline {
    display: grid;
    gap: 10px;
}

.timeline div {
    padding: 10px 12px;
    background: var(--surface);
    border-right: 3px solid var(--primary);
    border-radius: 8px;
}

.timeline strong {
    display: block;
}

.timeline span,
.timeline p {
    color: var(--muted);
    margin: 2px 0 0;
    font-size: 13px;
}

.settings-list {
    display: grid;
    gap: 10px;
}

.settings-item {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.date-picker {
    position: relative;
    display: grid;
    gap: 8px;
}

.date-trigger {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-weight: 800;
}

.date-trigger span:last-child {
    color: var(--muted);
    font-size: 13px;
}

.calendar-panel {
    display: grid;
    gap: 10px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.calendar-header {
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.icon-button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f1f5f9;
    font-size: 24px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.weekdays span {
    color: var(--muted);
    text-align: center;
    font-size: 12px;
    font-weight: 800;
}

.days button {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.days button.selected {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

#blazor-error-ui {
    position: fixed;
    inset-inline: 12px;
    bottom: 78px;
    z-index: 1000;
    display: none;
    padding: 12px;
    color: #991b1b;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 8px;
}

#blazor-error-ui .dismiss {
    float: left;
    cursor: pointer;
}

.loading-progress {
    display: block;
    width: 72px;
    height: 72px;
    margin: 28vh auto 12px;
}

.loading-progress circle {
    fill: none;
    stroke: #dbeafe;
    stroke-width: .6rem;
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: var(--primary);
    stroke-dasharray: calc(3.141 * 80%);
    animation: spin 1s linear infinite;
}

.loading-progress-text {
    text-align: center;
    color: var(--muted);
}

.loading-progress-text::after {
    content: "در حال بارگذاری...";
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (min-width: 680px) {
    .hero-panel {
        grid-template-columns: 1fr auto;
        align-items: center;
    }
}

@media (max-width: 430px) {
    .page-heading {
        display: grid;
    }

    .form-grid,
    .action-grid,
    .quick-grid {
        grid-template-columns: 1fr;
    }

    .inline-panel {
        display: grid;
    }
}
