@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800;900&display=swap');

:root{
  --primary:#4a2ec7;
  --primary-light:#6d39df;
  --primary-dark:#2f247d;
  --background:#f1f3fa;
  --card:#ffffff;
  --text:#171629;
  --muted:#85899b;
  --line:#e7e9f2;
  --pink:#cf4db2;
  --green:#0db777;
  --blue:#3979e9;
  --orange:#ed7f1f;
  --shadow:0 12px 30px rgba(48,40,94,.07);
}

*{box-sizing:border-box}
html{background:var(--background)}
body{
  margin:0;
  background:
    radial-gradient(circle at 10% 4%,rgba(83,58,197,.055),transparent 26%),
    var(--background);
  color:var(--text);
  font-family:'Vazirmatn',Tahoma,Arial,sans-serif;
}
a{text-decoration:none;color:inherit}
button,input,select,textarea{font:inherit}
svg{display:block}

.desktop-stage{min-height:100vh}
.sidebar,.desktop-topbar{display:none}
.app-shell{min-height:100vh}
.main-content{padding:14px 13px 102px}
.alert{padding:12px 14px;border-radius:14px;margin-bottom:12px;font-size:12px}
.alert.ok{background:#e7faf1;color:#087b55}
.alert.error{background:#ffebef;color:#b32042}

/* Mobile header */
.mobile-topbar{
  height:74px;
  background:#fff;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
  position:sticky;
  top:0;
  z-index:50;
}
.hamburger{border:0;background:transparent;color:var(--primary);font-size:27px;padding:4px}
.mobile-brand{display:flex;align-items:center;gap:10px}
.mobile-brand b{display:block;color:#38269c;font-size:23px;font-weight:900}
.mobile-brand small{display:block;color:var(--muted);font-size:9px}
.mobile-logo{width:45px;height:45px;border-radius:13px;background:linear-gradient(145deg,#5f35d6,#34217f);color:#fff;display:grid;place-items:center}
.mobile-logo svg{width:28px;height:28px}

/* Dashboard shared */
.dashboard{display:grid;gap:13px}
.stat-row{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.stat-card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:17px;
  padding:13px;
  min-height:137px;
  display:grid;
  grid-template-columns:1fr 44px;
  gap:8px;
  align-items:start;
}
.stat-copy{grid-column:1;text-align:right;padding-top:3px}
.stat-copy span{display:block;font-size:10px;font-weight:800}
.stat-copy strong{display:block;font-size:21px;font-weight:900;margin:11px 0 1px}
.stat-copy small{font-size:9px}
.stat-copy em{display:block;font-size:8px;color:var(--muted);font-style:normal;margin-top:6px}
.stat-icon{grid-column:2;width:44px;height:44px;border-radius:13px;display:grid;place-items:center}
.stat-icon svg{width:25px;height:25px}
.stat-icon.blue{background:#e7efff;color:var(--blue)}
.stat-icon.orange{background:#fff0df;color:var(--orange)}
.stat-icon.green{background:#e5f9ef;color:var(--green)}
.stat-icon.pink{background:#f5e3f4;color:var(--pink)}
.blue-border{border-color:#cddcff}
.orange-border{border-color:#f3d5b9}
.green-border{border-color:#cce8d8}
.pink-border{border-color:#ead4e8}

.wallet-card{
  position:relative;
  overflow:hidden;
  min-height:137px;
  border-radius:20px;
  padding:17px;
  color:#fff;
  background:linear-gradient(135deg,#7138e9 0%,#4d2abe 58%,#2f247d 100%);
}
.wallet-copy{
  position:relative;
  z-index:2;
  display:flex;
  align-items:center;
  gap:12px;
  width:62%;
  direction:ltr;
}
.wallet-illustration{width:57px;height:57px;border-radius:16px;background:#ffffff20;display:grid;place-items:center;flex:0 0 57px}
.wallet-illustration svg{width:48px;height:48px}
.wallet-text{direction:rtl}
.wallet-text span{font-size:11px;font-weight:800}
.wallet-text strong{display:block;font-size:27px;font-weight:900;margin-top:5px}
.wallet-text small{font-size:9px}
.wallet-chart{position:absolute;left:48%;right:5px;top:11px;bottom:7px}
.wallet-chart svg{width:100%;height:100%}
.chart-badge{display:none}

.action-row{display:none}
.panel{background:#fff;border:1px solid var(--line);border-radius:19px;padding:15px;box-shadow:var(--shadow)}
.panel-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:9px}
.panel-head h2{font-size:15px;margin:0;font-weight:900}
.panel-head a{font-size:10px;color:var(--primary)}
.desktop-table-wrap{display:none}
.mobile-tx-list{display:grid}
.mobile-tx-row{display:flex;align-items:center;justify-content:space-between;padding:11px 0;border-bottom:1px solid var(--line)}
.mobile-tx-row:last-child{border-bottom:0}
.mobile-tx-main{display:flex;align-items:center;gap:9px}
.mobile-tx-main b{display:block;font-size:10px}
.mobile-tx-main small{display:block;font-size:8px;color:var(--muted);margin-top:3px}
.mini-status{width:29px;height:29px;border-radius:50%;display:grid;place-items:center}
.mini-status svg{width:15px;height:15px}
.mini-status.green{background:#e6f8ef;color:var(--green)}
.mini-status.red{background:#ffe7eb;color:#eb4766}
.mobile-tx-amount{text-align:left}
.mobile-tx-amount strong{display:block;font-size:10px}
.mobile-tx-amount small{font-size:8px;color:var(--muted)}
.empty{text-align:center;color:var(--muted);font-size:11px;padding:22px}

/* PWA bottom navigation: exact right-to-left visual order */
.mobile-bottom-nav{
  direction:ltr;
  position:fixed;
  right:0;
  left:0;
  bottom:0;
  z-index:100;
  display:grid;
  grid-template-columns:repeat(5,1fr);
  min-height:82px;
  padding:12px 7px calc(10px + env(safe-area-inset-bottom));
  background:linear-gradient(90deg,#6b36dc,#4a2ec7,#33227f);
  border-radius:21px 21px 0 0;
  box-shadow:0 -12px 30px rgba(60,38,145,.23);
}
.mobile-bottom-nav a{direction:rtl;display:grid;place-items:center;color:#ffffffbd;gap:3px}
.bottom-svg{width:22px;height:22px}
.mobile-bottom-nav span{font-size:9px;font-weight:700}
.mobile-bottom-nav a.active{color:#fff}
.mobile-bottom-nav .center-add .bottom-svg{
  width:65px;
  height:65px;
  margin-top:-41px;
  padding:15px;
  border-radius:50%;
  color:#fff;
  background:linear-gradient(145deg,#ff65a0,#ff4c76);
  border:5px solid #5a35d2;
  box-shadow:0 10px 24px rgba(255,76,120,.36);
}

/* General pages */
.form-card,.range-form,.profile,.settings-list,.category-grid article,.add-category{
  background:#fff;border:1px solid var(--line);border-radius:20px;padding:16px;box-shadow:var(--shadow)
}
.form{display:grid;gap:14px}
label{display:grid;gap:7px;font-size:11px;color:var(--muted)}
input,select,textarea{width:100%;border:1px solid var(--line);background:#fbfbfe;border-radius:14px;padding:13px;color:var(--text);outline:none}
textarea{min-height:78px;resize:vertical}
.amount-box{background:#faf8ff;padding:15px;border-radius:18px}
.amount-box input{border:0;background:transparent;padding:6px 0;font-size:25px;font-weight:900}
.amount-box small{text-align:left}
.two{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.btn{border:0;border-radius:14px;padding:13px;font-weight:800;cursor:pointer}
.btn.primary{color:#fff;background:linear-gradient(145deg,var(--primary-light),var(--primary))}
.btn.success{color:#fff;background:linear-gradient(145deg,#22c98d,#0fa875)}
.info{background:#f1ebff;color:#6132bc;border-radius:14px;padding:11px;font-size:9px}
.tabs{display:flex;background:#e9eaf2;border-radius:14px;padding:4px;margin-bottom:13px}
.tabs a{flex:1;text-align:center;padding:8px;border-radius:11px;font-size:9px;color:var(--muted)}
.tabs .active{background:#fff;color:var(--primary);box-shadow:0 3px 9px #00000010}
.range-form{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-bottom:13px}
.range-form button{grid-column:1/-1}
.report-total{background:linear-gradient(145deg,#8240e8,#6830d1);color:#fff;border-radius:22px;padding:20px;margin-bottom:14px;text-align:center}
.report-total span{font-size:10px;opacity:.8}
.report-total strong{display:block;font-size:28px;margin:7px}
.report-total small,.report-total p{font-size:9px;opacity:.8}
.bars{display:grid;gap:13px}
.bars article>div:first-child{display:flex;justify-content:space-between;font-size:10px}
.bars span{color:var(--muted)}
.bar{height:8px;background:#eeeef5;border-radius:99px;overflow:hidden;margin:7px 0}
.bar i{display:block;height:100%;background:var(--primary)}
.bars small{font-size:8px;color:var(--muted)}
.add-category summary{font-size:10px;color:var(--primary);cursor:pointer}
.add-category form{margin-top:14px}
.category-grid h2{font-size:12px;color:var(--primary);margin:16px 0 7px}
.category-grid article{margin-bottom:8px}
.category-grid b{font-size:10px}
.category-grid small{display:block;color:var(--muted);font-size:8px;margin-top:4px}
.profile{text-align:center;background:linear-gradient(145deg,#8541e9,#6830d1);color:#fff}
.profile>div{width:66px;height:66px;border-radius:50%;background:#ffffff25;display:grid;place-items:center;font-size:32px;margin:auto}
.profile h2{font-size:15px;margin:9px 0 3px}
.profile p{font-size:9px;opacity:.75}
.settings-list a{display:grid;grid-template-columns:38px 1fr 18px;align-items:center;padding:13px 4px;border-bottom:1px solid var(--line)}
.settings-list a:last-child{border:0}
.settings-list i{font-style:normal;font-size:19px}
.settings-list b{font-size:10px}
.settings-list small{display:block;color:var(--muted);font-size:8px;margin-top:3px}
.settings-list em{font-style:normal;color:#aaa}
.settings-list .danger{color:#ef476f}

.auth-bg{min-height:100vh;display:grid;place-items:center;padding:18px;background:linear-gradient(145deg,#f1ebff,#f8f8fc)}
.auth-card{width:min(420px,100%);background:#fff;border-radius:26px;padding:24px;box-shadow:var(--shadow);text-align:center}
.auth-logo{width:64px;height:64px;border-radius:21px;background:linear-gradient(145deg,var(--primary-light),var(--primary));color:#fff;display:grid;place-items:center;margin:auto;font-size:28px;font-weight:900}
.auth-card h1{font-size:19px;margin:13px 0 5px}
.auth-card>p{font-size:10px;color:var(--muted);margin-bottom:18px}
.auth-card form{text-align:right}

/* Desktop closely follows the reference */
@media(min-width:900px){
  body{padding:14px}

  .desktop-stage{
    position:relative;
    width:min(1420px,calc(100vw - 28px));
    min-height:calc(100vh - 28px);
    margin:auto;
  }

  .app-shell{
    width:calc(100% - 150px);
    min-height:calc(100vh - 28px);
    background:#fff;
    border-radius:23px;
    overflow:hidden;
    box-shadow:0 20px 58px rgba(43,35,89,.10);
  }

  .sidebar{
    display:flex;
    position:absolute;
    right:0;
    top:90px;
    bottom:0;
    width:150px;
    flex-direction:column;
    padding:17px 11px 15px;
    color:#fff;
    background:linear-gradient(180deg,#4b2fc7 0%,#2e247d 100%);
    border-radius:0 20px 20px 0;
    box-shadow:0 18px 46px rgba(47,35,127,.19);
  }

  .sidebar-mini-brand{
    min-height:77px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    border-bottom:1px solid #ffffff26;
    color:#fff;
  }
  .sidebar-brand-icon{width:40px;height:40px;border-radius:12px;background:#ffffff20;display:grid;place-items:center}
  .sidebar-brand-icon svg{width:25px;height:25px}
  .sidebar-mini-brand small{text-align:center;font-size:6px;line-height:1.55;opacity:.72;margin-top:6px}

  .sidebar-nav{display:grid;gap:8px;margin-top:15px}
  .sidebar-nav a{
    display:flex;
    align-items:center;
    justify-content:space-between;
    min-height:44px;
    padding:9px 11px;
    border-radius:12px;
    color:#ffffffd2;
    font-size:10px;
  }
  .sidebar-nav a.active,.sidebar-nav a:hover{background:#ffffff22;color:#fff}
  .sidebar-svg{width:18px;height:18px;order:2}
  .sidebar-nav span{order:1}

  .sidebar-user{
    margin-top:auto;
    display:grid;
    grid-template-columns:27px 1fr 14px;
    align-items:center;
    gap:6px;
    padding:13px 2px 0;
    border-top:1px solid #ffffff25;
  }
  .user-avatar{width:25px;height:25px;border-radius:50%;background:#ffffff32;display:grid;place-items:center;font-size:7px}
  .sidebar-user b{display:block;font-size:8px}
  .sidebar-user small{display:block;font-size:6px;opacity:.68}
  .sidebar-user>span{font-size:15px}

  .mobile-topbar,.mobile-bottom-nav{display:none}

  .desktop-topbar{
    display:grid;
    grid-template-columns:1fr 1fr 1fr;
    align-items:center;
    min-height:102px;
    padding:16px 22px 7px;
  }

  .topbar-actions{grid-column:1;display:flex;justify-content:flex-start;gap:10px;direction:rtl}
  .topbar-actions a{display:flex;align-items:center;gap:7px;padding:11px 16px;border-radius:11px;font-size:9px;font-weight:800}
  .topbar-actions svg{width:16px;height:16px}
  .topup-button{background:linear-gradient(145deg,#5e34d7,#3d289a);color:#fff;box-shadow:0 9px 22px rgba(74,46,199,.24)}
  .expense-button{background:#fff;border:1px solid #dedfec;box-shadow:0 7px 18px rgba(38,35,70,.06)}

  .topbar-center{grid-column:2;text-align:center}
  .topbar-center h1{font-size:18px;margin:0;font-weight:900}
  .topbar-center p{font-size:8px;color:var(--muted);margin:3px 0 0}

  .topbar-brand{grid-column:3;display:flex;align-items:center;justify-content:flex-end;gap:10px}
  .topbar-brand>div:first-child{text-align:right}
  .topbar-brand b{display:block;color:#382795;font-size:24px;font-weight:900}
  .topbar-brand small{display:block;font-size:7px;color:var(--muted);margin-top:3px}
  .topbar-logo{width:48px;height:48px;border-radius:13px;background:linear-gradient(145deg,#5e35d7,#33217f);color:#fff;display:grid;place-items:center}
  .topbar-logo svg{width:30px;height:30px}

  .main-content{padding:8px 22px 30px}
  .dashboard{gap:16px}

  .stat-row{grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;direction:rtl}
  .stat-card{
    min-height:126px;
    padding:16px 17px;
    grid-template-columns:1fr 51px;
    gap:12px;
    border-radius:17px;
  }
  .stat-copy span{font-size:10px}
  .stat-copy strong{font-size:24px;margin-top:8px}
  .stat-copy small{font-size:8px}
  .stat-copy em{font-size:7px;margin-top:5px}
  .stat-icon{width:51px;height:51px;border-radius:15px}
  .stat-icon svg{width:28px;height:28px}

  .wallet-card{
    min-height:148px;
    padding:20px 25px;
    border-radius:19px;
  }
  .wallet-copy{
    position:absolute;
    left:27px;
    top:50%;
    transform:translateY(-50%);
    width:34%;
    gap:15px;
  }
  .wallet-illustration{width:74px;height:74px;flex-basis:74px;border-radius:20px}
  .wallet-illustration svg{width:62px;height:62px}
  .wallet-text span{font-size:12px}
  .wallet-text strong{font-size:37px}
  .wallet-text small{font-size:10px}
  .wallet-chart{left:42%;right:22px;top:12px;bottom:12px}
  .chart-badge{display:block;position:absolute;left:54%;top:25%;padding:5px 8px;border-radius:7px;background:#ffffff16;border:1px solid #ffffff1b;font-size:7px}

  .action-row{display:grid;grid-template-columns:repeat(5,1fr);gap:13px;direction:rtl}
  .action-card{
    min-height:80px;
    display:grid;
    grid-template-columns:1fr 47px;
    align-items:center;
    gap:10px;
    padding:13px 14px;
    background:#fff;
    border:1px solid var(--line);
    border-radius:16px;
    box-shadow:var(--shadow);
  }
  .action-copy{text-align:right}
  .action-copy b{display:block;font-size:10px}
  .action-copy small{display:block;font-size:7px;color:var(--muted);margin-top:3px}
  .action-icon{width:47px;height:47px;border-radius:14px;display:grid;place-items:center}
  .action-icon svg{width:25px;height:25px}
  .action-icon.pink{background:#f6e3f3;color:#d247b1}
  .action-icon.green{background:#e4f8ed;color:#0eaf72}
  .action-icon.blue{background:#e7edff;color:#4f70df}
  .action-icon.sky{background:#e8f2ff;color:#3a82e9}
  .action-icon.orange{background:#fff0df;color:#ed851d}

  .panel{padding:17px;border-radius:18px}
  .panel-head h2{font-size:14px}
  .panel-head a{font-size:8px}
  .desktop-table-wrap{display:block;overflow:auto}
  .mobile-tx-list{display:none}
  .transactions-table{width:100%;border-collapse:separate;border-spacing:0;font-size:8px;border:1px solid var(--line);border-radius:11px;overflow:hidden}
  .transactions-table th{background:#f7f7fb;color:#717589;padding:8px;text-align:center;font-weight:700}
  .transactions-table td{padding:8px;text-align:center;border-top:1px solid var(--line)}
  .badge{display:inline-block;min-width:45px;padding:3px 7px;border-radius:99px;font-size:7px;font-weight:800}
  .badge-green{background:#e5f8ed;color:#0d9f68}
  .badge-red{background:#ffe7eb;color:#e33f60}

  .form-card{max-width:880px;margin:auto;padding:24px}
  .form{gap:16px}
  .amount-box{padding:20px}
  .amount-box input{font-size:31px}
  .two{gap:16px}
  .tabs{max-width:650px}
  .range-form{grid-template-columns:1fr 1fr auto;align-items:end}
  .range-form button{grid-column:auto;min-width:120px}
  .report-total{text-align:right;padding:25px 29px}
  .category-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:9px 14px}
  .category-grid h2{grid-column:1/-1;margin-bottom:0}
  .category-grid article{margin:0}
  .profile,.settings-list{max-width:850px;margin:0 auto 16px}
}

@media(min-width:1500px){
  .desktop-stage{width:1420px}
}


/* ===== v8 desktop overlap fix ===== */
@media(min-width:900px){
  .desktop-stage{
    position:relative !important;
    display:block !important;
  }

  .app-shell{
    position:absolute !important;
    top:0 !important;
    bottom:0 !important;
    left:0 !important;
    right:162px !important;
    width:auto !important;
    min-height:calc(100vh - 28px) !important;
    margin:0 !important;
    z-index:1 !important;
  }

  .sidebar{
    position:absolute !important;
    top:90px !important;
    right:0 !important;
    bottom:0 !important;
    left:auto !important;
    width:150px !important;
    z-index:5 !important;
  }

  .desktop-topbar,
  .main-content{
    width:100% !important;
    max-width:none !important;
  }
}

@media(min-width:1500px){
  .desktop-stage{
    width:min(1420px,calc(100vw - 28px)) !important;
  }
}
