:root {
    --ink: #172033;
    --muted: #748099;
    --line: #e6eaf1;
    --surface: #fff;
    --bg: #f4f6fa;
    --primary: #8b3d72;
    --primary-dark: #63264f;
    --accent: #d8a45d;
    --success: #138a63;
    --danger: #c33b4b;
    --warning: #c78319;
    --info: #347aa5;
    --shadow: 0 18px 48px rgba(25, 32, 56, .08);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: "Tajawal", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; color: #fff; background: linear-gradient(180deg, #33182c, #1e1927); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 28px; }
.brand-mark { width: 45px; height: 45px; border-radius: 15px; display: inline-grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); font-weight: 800; font-size: 22px; box-shadow: 0 10px 24px rgba(139,61,114,.3); }
.brand b, .brand small, .sidebar-user b, .sidebar-user small { display: block; }
.brand small, .sidebar-user small { color: #c8bec8; margin-top: 2px; }
.sidebar nav { display: grid; gap: 7px; }
.sidebar nav a { padding: 12px 14px; border-radius: 12px; color: #d9d1d9; display: flex; gap: 11px; align-items: center; }
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar nav a.active { box-shadow: inset -3px 0 var(--accent); }
.sidebar-user { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.12); display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.13); display: grid; place-items: center; }
.main-area { min-width: 0; }
.topbar { height: 94px; padding: 0 32px; background: rgba(255,255,255,.88); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 22px; margin: 0; }
.topbar-actions { margin-right: auto; display: flex; align-items: center; gap: 10px; }
.eyebrow { margin: 0 0 3px; color: var(--primary); font-weight: 700; font-size: 12px; letter-spacing: .04em; }
.content { padding: 28px 32px 50px; max-width: 1600px; width: 100%; margin: 0 auto; }
.grid { display: grid; gap: 18px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 24px; }
.stat-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.stat-card { padding: 20px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 80px; height: 80px; border-radius: 50%; left: -25px; top: -25px; background: color-mix(in srgb, var(--tone, var(--primary)) 12%, transparent); }
.stat-card p { margin: 0 0 12px; color: var(--muted); }
.stat-card strong { font-size: 25px; }
.stat-card small { display: block; color: var(--muted); margin-top: 8px; }
.panel { padding: 22px; margin-bottom: 22px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 18px; }
.panel-header h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.btn { border: 0; border-radius: 11px; padding: 10px 16px; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 7px; font-weight: 700; }
.btn.primary { color: #fff; background: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.soft { color: var(--primary-dark); background: #f4e9f0; }
.btn.danger { color: #fff; background: var(--danger); }
.btn.compact { padding: 8px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.menu-toggle { display: none; border: 0; background: transparent; font-size: 24px; }
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: 10px; align-items: end; padding: 15px; background: #fafbfc; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 16px; }
label { display: grid; gap: 7px; color: #4e5870; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #dbe0e9; border-radius: 10px; background: #fff; padding: 10px 12px; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139,61,114,.1); }
textarea { min-height: 90px; resize: vertical; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 850px; background: #fff; }
th, td { padding: 13px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: #5d687e; font-size: 12px; background: #fafbfc; }
tbody tr:hover { background: #fcfafc; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.badge.success { color: #087151; background: #ddf5ec; }
.badge.warning { color: #8d5a08; background: #fff0cf; }
.badge.info { color: #276687; background: #dff1fb; }
.badge.muted { color: #667085; background: #edf0f5; }
.badge.danger { color: #a12436; background: #fde5e8; }
.actions { display: flex; gap: 7px; }
.alert { padding: 12px 15px; border-radius: 12px; margin-bottom: 18px; background: #e9eef7; }
.alert.success { color: #087151; background: #ddf5ec; }
.alert.danger { color: #9e2032; background: #fde5e8; }
.alert.warning { color: #80530d; background: #fff0cf; }
.two-columns { grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.money-preview { display: flex; justify-content: space-between; align-items: center; border-radius: 12px; padding: 13px 15px; background: #f9f3f7; color: var(--primary-dark); font-weight: 800; }
.measurements { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: radial-gradient(circle at top right, #f4e8ef, transparent 35%), #f4f6fa; }
.login-card { width: min(440px, 100%); background: #fff; padding: 34px; border-radius: 24px; border: 1px solid var(--line); box-shadow: 0 24px 65px rgba(40,25,40,.12); }
.login-card .brand-mark { margin-bottom: 20px; }
.login-card h1 { margin: 4px 0 6px; }
.stack { display: grid; gap: 15px; margin-top: 24px; }
dialog { border: 0; border-radius: 18px; width: min(560px, calc(100% - 30px)); padding: 0; box-shadow: 0 25px 80px rgba(20,20,35,.3); }
dialog::backdrop { background: rgba(20,18,28,.55); backdrop-filter: blur(3px); }
.dialog-body { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; }
.icon-button { border: 0; background: #f1f3f6; border-radius: 50%; width: 34px; height: 34px; cursor: pointer; }
.empty { padding: 45px 20px; text-align: center; color: var(--muted); }
.customer-dialog { width: min(900px, calc(100% - 30px)); }
.notification-button { position: relative; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: #fff; cursor: pointer; font-size: 19px; display: grid; place-items: center; }
.notification-button:hover { background: #faf5f8; border-color: #decbd8; }
.notification-button b { position: absolute; top: -6px; left: -5px; min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; border-radius: 99px; color: #fff; background: var(--danger); border: 2px solid #fff; font-size: 10px; }
.notification-dialog { width: min(680px, calc(100% - 30px)); }
.notification-list { display: grid; gap: 9px; max-height: min(520px, 70vh); overflow: auto; }
.notification-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.notification-item:hover { border-color: #d7bccc; background: #fcf8fb; }
.notification-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--info); }
.notification-item.overdue .notification-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(195,59,75,.1); }
.notification-item.today .notification-dot { background: var(--warning); box-shadow: 0 0 0 5px rgba(199,131,25,.1); }
.notification-details b, .notification-details small, .notification-date small { display: block; }
.notification-details small, .notification-date small { color: var(--muted); margin-top: 3px; }
.notification-date { text-align: left; font-weight: 700; }
.notification-item.overdue .notification-date { color: var(--danger); }
.notification-empty { padding: 25px 10px; }
.sidebar-user-profile { min-width: 0; }
.dashboard-welcome { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 24px 28px; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 22px; color: #fff; background: linear-gradient(135deg, #401b36, #8b3d72); box-shadow: var(--shadow); }
.dashboard-welcome h2 { margin: 2px 0 7px; font-size: 26px; }
.dashboard-welcome .eyebrow, .dashboard-welcome .muted { color: rgba(255,255,255,.78); }
.dashboard-welcome-mark { width: 72px; height: 72px; flex: 0 0 72px; border-radius: 22px; display: grid; place-items: center; font-size: 32px; font-weight: 800; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2); }
.dashboard-navigation { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.dashboard-nav-card { --card-tone: var(--primary); position: relative; min-height: 205px; padding: 25px; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.dashboard-nav-card::after { content: ""; position: absolute; width: 150px; height: 150px; left: -50px; top: -55px; border-radius: 50%; background: color-mix(in srgb, var(--card-tone) 12%, transparent); }
.dashboard-nav-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--card-tone) 35%, var(--line)); box-shadow: 0 24px 58px rgba(25,32,56,.13); }
.dashboard-nav-card.orders { --card-tone: #8b3d72; }
.dashboard-nav-card.customers { --card-tone: #347aa5; }
.dashboard-nav-card.workers { --card-tone: #138a63; }
.dashboard-nav-card.account { --card-tone: #c78319; }
.dashboard-nav-icon { width: 66px; height: 66px; display: grid; place-items: center; border-radius: 20px; color: #fff; background: var(--card-tone); font-size: 29px; font-weight: 800; box-shadow: 0 13px 28px color-mix(in srgb, var(--card-tone) 28%, transparent); }
.dashboard-nav-content { position: relative; z-index: 1; }
.dashboard-nav-content > b { display: block; margin-bottom: 8px; font-size: 23px; }
.dashboard-nav-content > small { display: block; min-height: 44px; color: var(--muted); line-height: 1.65; }
.dashboard-nav-stats { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: #596479; font-size: 13px; }
.dashboard-nav-stats strong { color: var(--card-tone); font-size: 18px; }
.dashboard-nav-stats i { width: 4px; height: 4px; border-radius: 50%; background: #b6bdc9; }
.dashboard-nav-arrow { position: relative; z-index: 1; font-size: 25px; color: var(--card-tone); transition: transform .2s ease; }
.dashboard-nav-card:hover .dashboard-nav-arrow { transform: translateX(-5px); }
.account-layout { grid-template-columns: minmax(270px,.65fr) minmax(0,1.35fr); }
.account-profile-panel { text-align: center; position: sticky; top: 120px; }
.account-profile-avatar { width: 92px; height: 92px; margin: 5px auto 16px; display: grid; place-items: center; border-radius: 28px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); font-size: 38px; font-weight: 800; box-shadow: 0 16px 35px rgba(139,61,114,.22); }
.account-profile-panel h2 { margin: 0 0 11px; }
.account-summary { display: grid; gap: 0; margin: 25px 0 0; text-align: right; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.account-summary div { padding: 13px 15px; display: flex; justify-content: space-between; gap: 15px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.account-summary div:last-child { border-bottom: 0; }
.account-summary dt { color: var(--muted); }
.account-summary dd { margin: 0; font-weight: 700; }
.account-form { margin-top: 0; }
.account-password-box { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #fafbfc; }
.account-password-box h3, .account-password-box p { margin: 0; }

/* Familiar tailoring order sheet */
.legacy-orders-heading { text-align: center; margin: 5px 0 20px; }
.legacy-orders-heading h2 { margin: 0; font-size: 25px; }
.legacy-orders-heading p { margin: 4px 0 0; font-size: 20px; font-weight: 800; }
.orders-summary { margin-bottom: 22px; }
.orders-summary .stat-card { min-height: 142px; display: flex; flex-direction: column; justify-content: center; }
.orders-summary .stat-card strong { position: relative; z-index: 1; }
.orders-summary-debt strong { color: var(--danger); }
.legacy-filter-panel { background: #fff; border: 1px solid #d9dee7; border-radius: 7px; padding: 12px; margin-bottom: 16px; }
.legacy-filters { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto; gap: 9px; align-items: end; }
.legacy-search { grid-column: 1 / -2; }
.legacy-search:has([data-live-order-search]) { grid-column: 1 / -1; }
.order-sheet[hidden] { display: none !important; }
.orders-workspace { display: grid; gap: 16px; }
.order-sheet { border: 2px solid #20242c; background: #fff; transition: box-shadow .2s ease, border-color .2s ease; }
.order-sheet.is-dirty { border-color: #e49b16; box-shadow: 0 0 0 3px rgba(228,155,22,.16); }
.order-sheet-scroll { overflow-x: auto; }
.measurement-sheet {
    min-width: 1050px;
    table-layout: fixed;
    border-collapse: collapse;
    background: transparent;
    direction: ltr;
}
.measurement-sheet .actions-col { width: 90px; }
.measurement-sheet .measure-col { width: 10.5%; }
.measurement-sheet .details-col { width: 185px; }
.measurement-sheet .labels-col { width: 78px; }
.measurement-sheet th, .measurement-sheet td {
    border: 1px solid #292d34;
    padding: 5px;
    height: 39px;
    text-align: center;
    white-space: normal;
    background: transparent;
    color: #111827;
    direction: rtl;
}
.measurement-sheet th { font-size: 14px; font-weight: 800; }
.measurement-sheet input,
.measurement-sheet select,
.measurement-sheet textarea {
    border: 0;
    border-radius: 0;
    padding: 5px 7px;
    min-height: 29px;
    background: transparent !important;
    box-shadow: none;
    text-align: right;
}
.measurement-sheet input:focus,
.measurement-sheet select:focus,
.measurement-sheet textarea:focus {
    background: rgba(255,255,255,.16) !important;
    outline: 2px solid #159ec1;
    box-shadow: none;
}
.measurement-sheet textarea { min-height: 78px; height: 100%; resize: vertical; }
.measurement-sheet .side-label { font-size: 14px; }
.customer-cell { padding: 2px !important; white-space: nowrap !important; }
.customer-cell input[type="text"] { display: block; width: 100%; }
.money-cell { display: grid; grid-template-columns: 24px 1fr; align-items: center; padding: 3px 7px !important; text-align: left !important; }
.money-cell span { font-weight: 700; }
.money-cell strong { text-align: right; padding: 5px 7px; }
.remaining-cell.has-debt { background: #e23249 !important; color: #111 !important; }
.remaining-cell.has-debt strong { color: #111; background: transparent; }
.order-action-cell { vertical-align: middle; }
.sheet-actions { display: flex; justify-content: center; gap: 2px; direction: ltr; }
.sheet-btn { width: 32px; height: 32px; border: 0; color: #fff; cursor: pointer; font-size: 18px; font-weight: 800; }
.sheet-btn.save { background: #129c7a; }
.sheet-btn.save.add { width: 66px; font-size: 13px; background: #10b9de; border-radius: 5px; }
.sheet-btn.duplicate { background: #efa600; }
.sheet-btn.delete { background: #ef334f; }
.sheet-number { display: block; margin-top: 10px; font-weight: 800; }
.order-tone-new { background: #fff; }
.order-tone-warning { background: #ffdf82; }
.order-tone-info { background: #7ed9e9; }
.order-tone-success { background: #9bdeb6; }
.order-tone-muted { background: #f5f5f5; }
.sheet-footer { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 8px 10px; border-top: 1px solid #252a31; font-size: 12px; }
.status-steps { display: flex; gap: 5px; }
.status-steps form { margin: 0; }
.status-steps button { border: 1px solid rgba(0,0,0,.28); border-radius: 5px; padding: 5px 9px; background: rgba(255,255,255,.7); cursor: pointer; }
.status-steps button.active { color: #fff; background: #1d2635; }
.save-state { margin-right: auto; color: #5c6675; }
.is-dirty .save-state { color: #9a6100; font-weight: 800; }
@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filters { grid-template-columns: repeat(2, 1fr); }
    .two-columns { grid-template-columns: 1fr; }
    .account-profile-panel { position: static; }
    .legacy-filters { grid-template-columns: repeat(3, 1fr); }
    .legacy-search { grid-column: 1 / -2; }
}
@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; right: -270px; width: 250px; transition: right .25s ease; }
    .sidebar.open { right: 0; }
    .menu-toggle { display: block; }
    .topbar { height: 78px; padding: 0 16px; }
    .topbar-actions .btn { display: none; }
    .content { padding: 18px 14px 35px; }
    .stats-grid, .filters, .form-grid, .measurements { grid-template-columns: 1fr; }
    .panel { padding: 16px; }
    .dashboard-welcome { padding: 20px; }
    .dashboard-welcome-mark { width: 55px; height: 55px; flex-basis: 55px; border-radius: 17px; font-size: 25px; }
    .dashboard-navigation { grid-template-columns: 1fr; }
    .dashboard-nav-card { min-height: 170px; padding: 19px; grid-template-columns: auto 1fr; }
    .dashboard-nav-icon { width: 54px; height: 54px; border-radius: 16px; font-size: 24px; }
    .dashboard-nav-arrow { display: none; }
    .orders-summary { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .orders-summary .stat-card { min-height: 120px; padding: 15px; }
    .orders-summary .stat-card strong { font-size: 19px; }
    .legacy-filters { grid-template-columns: 1fr 1fr; }
    .legacy-search { grid-column: 1 / -1; }
    .measurement-sheet { min-width: 980px; }
}
