/* ===================================================================
   کوله (Kolea) — Design System
   Theme: "کیف ابزار" (the toolbelt) — every utility lives in its own
   pocket, tagged with a stitched zip-pull badge. Dark workshop canvas,
   amber pull-tabs, teal stitching for state/success.
   =================================================================== */

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

:root{
  /* --- Color tokens --- */
  --bg:            #11161c;
  --bg-soft:       #161d25;
  --surface:       #1a222b;
  --surface-2:     #212b35;
  --border:        #2a3540;
  --border-soft:   #232d37;

  --text:          #edeff2;
  --text-dim:      #aab4c0;
  --text-mute:     #71808f;

  --amber:         #e8a33d;
  --amber-soft:    #f0bd6b;
  --amber-dim:     #503a1d;

  --teal:          #36c99a;
  --teal-dim:      #163b30;

  --red:           #e15c5c;
  --red-dim:       #4a2424;

  --ring: 0 0 0 3px rgba(232,163,61,.28);

  /* --- Type --- */
  --font-fa: 'Vazirmatn', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* --- Layout --- */
  --sidebar-w: 264px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 8px 28px -8px rgba(0,0,0,.45);
}

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 0%, rgba(232,163,61,.07), transparent 38%),
    radial-gradient(circle at 90% 18%, rgba(54,201,154,.05), transparent 40%);
  color: var(--text);
  font-family: var(--font-fa);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  direction: rtl;
}
.ltr{ direction: ltr; unicode-bidi: isolate; font-family: var(--font-mono); }

h1,h2,h3,h4{ margin:0 0 .4em; font-weight:700; letter-spacing:-.01em; }
p{ margin:0 0 1em; color: var(--text-dim); }
a{ color: var(--amber-soft); text-decoration:none; }
a:hover{ text-decoration:underline; }
small{ color: var(--text-mute); }

button{ font-family: inherit; }
:focus-visible{ outline:none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ===================== Stitched pocket-tab badge (signature) ===================== */
.patch{
  position: relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 46px; height:46px;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1.5px dashed var(--border);
  color: var(--amber-soft);
  flex-shrink:0;
}
.patch svg{ width:22px; height:22px; }
.patch::after{
  content:"";
  position:absolute; inset:5px;
  border-radius: 6px;
  border: 1px solid rgba(232,163,61,.18);
  pointer-events:none;
}

/* ===================== App shell ===================== */
.app-shell{
  display:flex;
  min-height:100vh;
}

.sidebar{
  width: var(--sidebar-w);
  flex-shrink:0;
  background: var(--bg-soft);
  border-left: 1px solid var(--border-soft);
  display:flex;
  flex-direction:column;
  padding: 22px 16px;
  position: sticky;
  top:0; height:100vh;
}
.brand{
  display:flex; align-items:center; gap:10px;
  padding: 4px 8px 22px;
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.brand .mark{
  width:34px;height:34px;border-radius:9px;
  background: linear-gradient(150deg, var(--amber), #c9802a);
  display:flex;align-items:center;justify-content:center;
  font-weight:800; color:#1a1306; font-size:16px;
}
.brand .name{ font-weight:800; font-size:18px; }
.brand .name span{ color: var(--amber-soft); }

.nav-section-label{
  font-size:11.5px; color:var(--text-mute);
  letter-spacing:.04em; margin: 18px 10px 8px;
}
.nav-link{
  display:flex; align-items:center; gap:10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14.5px;
  font-weight:500;
  margin-bottom:2px;
  border: 1px solid transparent;
}
.nav-link svg{ width:18px;height:18px; flex-shrink:0; opacity:.85; }
.nav-link:hover{ background: var(--surface); color: var(--text); text-decoration:none; }
.nav-link.active{
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--amber-soft);
}
.nav-link .tag-count{
  margin-right:auto; margin-left:0;
  font-family: var(--font-mono);
  font-size:10.5px; color:var(--text-mute);
  background: var(--surface); border:1px solid var(--border);
  border-radius: 6px; padding:1px 6px;
}

.sidebar-foot{
  margin-top:auto;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.user-chip{
  display:flex; align-items:center; gap:10px;
  padding: 8px; border-radius: var(--radius-sm);
}
.user-chip .avatar{
  width:34px;height:34px;border-radius:50%;
  background: var(--surface-2); border:1px solid var(--border);
  display:flex;align-items:center;justify-content:center;
  font-weight:700; font-size:13px; color: var(--teal);
}
.user-chip .meta{ flex:1; min-width:0; }
.user-chip .meta .nm{ font-size:13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.user-chip .meta .em{ font-size:11.5px; color:var(--text-mute); direction:ltr; text-align:right; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block;}
.logout-btn{
  width:100%; margin-top:10px;
  background:none; border:1px solid var(--border);
  color: var(--text-dim); border-radius: var(--radius-sm);
  padding: 8px; font-size:13px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:6px;
}
.logout-btn:hover{ border-color: var(--red); color: var(--red); }

.main{
  flex:1; min-width:0;
  padding: 28px 36px 60px;
}
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 26px;
}
.topbar .crumbs{ font-size:12.5px; color:var(--text-mute); }
.topbar .crumbs b{ color: var(--text-dim); font-weight:600; }
.page-head{ margin-bottom: 26px; display:flex; align-items:flex-start; gap:14px; }
.page-head h1{ font-size: 23px; }
.page-head .desc{ margin:2px 0 0; max-width:560px; }

/* ===================== Cards / surfaces ===================== */
.card{
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-pad{ padding: 24px; }
.card-head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border-soft);
}
.card-head h3{ font-size:15.5px; margin:0; }

.tool-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(250px,1fr));
  gap: 16px;
}
.tool-card{
  display:block;
  background: var(--surface);
  border:1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color .15s, transform .15s;
}
.tool-card:hover{ border-color: var(--amber); text-decoration:none; transform: translateY(-2px); }
.tool-card .top-row{ display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:14px;}
.tool-card h4{ font-size:15.5px; margin:0 0 4px; color: var(--text); }
.tool-card p{ font-size:13px; margin:0; }
.tool-card .arrow{ color:var(--text-mute); font-size:18px; }
.tool-card:hover .arrow{ color: var(--amber-soft); }

/* ===================== Form elements ===================== */
.field{ margin-bottom: 18px; }
.field label{
  display:flex; align-items:center; justify-content:space-between;
  font-size: 13px; font-weight:600; color: var(--text-dim); margin-bottom:7px;
}
.field label .hint{ font-weight:400; color: var(--text-mute); font-size:12px; }

.input, textarea.input, select.input{
  width:100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder{ color: var(--text-mute); }
.input:focus, textarea.input:focus{ border-color: var(--amber); box-shadow: var(--ring); outline:none; }
.input-mono{ font-family: var(--font-mono); direction:ltr; text-align:left; }

.input-group{ position:relative; display:flex; }
.input-group .input{ border-radius: var(--radius-sm); }
.input-group .icon-btn{
  position:absolute; left:6px; top:50%; transform:translateY(-50%);
  background:none; border:none; color:var(--text-mute); cursor:pointer;
  padding:6px; border-radius:6px; display:flex;
}
.input-group .icon-btn:hover{ color: var(--amber-soft); background: var(--surface-2); }

.checkbox-row{ display:flex; align-items:center; gap:9px; padding:9px 0; cursor:pointer; user-select:none; }
.checkbox-row input[type=checkbox]{
  width:18px;height:18px; accent-color: var(--amber); cursor:pointer;
}
.checkbox-row span{ font-size:14px; color: var(--text); }
.checkbox-row .ex{ color: var(--text-mute); font-family: var(--font-mono); direction:ltr; font-size:12px; }

.slider-row{ display:flex; align-items:center; gap:14px; }
input[type=range]{
  -webkit-appearance:none; flex:1; height:5px; border-radius:5px;
  background: var(--border); cursor:pointer;
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; width:18px;height:18px;border-radius:50%;
  background: var(--amber); border:3px solid var(--bg);box-shadow:0 0 0 1px var(--amber);
  cursor:pointer;
}
.slider-val{
  font-family: var(--font-mono); background: var(--surface-2); border:1px solid var(--border);
  border-radius:7px; padding:4px 10px; font-size:13.5px; min-width:38px; text-align:center;
}

/* ===================== Buttons ===================== */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 14.5px; font-weight:600;
  border:1px solid transparent;
  cursor:pointer;
  transition: filter .15s, transform .1s, background .15s;
}
.btn:active{ transform: scale(.98); }
.btn-primary{ background: linear-gradient(150deg, var(--amber-soft), var(--amber)); color:#1a1306; }
.btn-primary:hover{ filter:brightness(1.08); }
.btn-secondary{ background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover{ border-color: var(--amber); color: var(--amber-soft); }
.btn-ghost{ background:none; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover{ border-color: var(--text-dim); color: var(--text); }
.btn-block{ width:100%; }
.btn-sm{ padding:7px 12px; font-size:13px; }
.btn[disabled]{ opacity:.55; cursor:not-allowed; }

/* ===================== Misc components ===================== */
.divider-label{
  display:flex; align-items:center; gap:10px; color:var(--text-mute);
  font-size:12.5px; margin: 18px 0;
}
.divider-label::before, .divider-label::after{ content:""; flex:1; height:1px; background: var(--border); }

.badge{
  display:inline-flex; align-items:center; gap:5px;
  font-size:11.5px; font-weight:600; padding:3px 9px; border-radius:99px;
  border:1px solid var(--border);
}
.badge-amber{ background: var(--amber-dim); color: var(--amber-soft); border-color:#6b4d24; }
.badge-teal{ background: var(--teal-dim); color: var(--teal); border-color:#1f5c47; }
.badge-red{ background: var(--red-dim); color: var(--red); border-color:#6b3030; }

.toast{
  position: fixed; bottom: 24px; left:50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border:1px solid var(--border);
  color: var(--text); padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: var(--shadow-card);
  display:flex; align-items:center; gap:8px;
  opacity:0; pointer-events:none; transition: opacity .2s, transform .2s;
  z-index: 999;
}
.toast.show{ opacity:1; transform: translateX(-50%) translateY(0); pointer-events:auto; }
.toast .dot{ width:7px;height:7px;border-radius:50%; background: var(--teal); flex-shrink:0; }

table.simple{ width:100%; border-collapse:collapse; font-size:13.5px; }
table.simple th{
  text-align:right; color:var(--text-mute); font-weight:600; font-size:12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-soft);
}
table.simple td{ padding: 12px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text); }
table.simple tr:last-child td{ border-bottom:none; }
table.simple .mono{ font-family: var(--font-mono); direction:ltr; text-align:left; display:inline-block; color: var(--text-dim); }

.empty-state{
  text-align:center; padding: 50px 20px; color: var(--text-mute);
}
.empty-state .patch{ margin: 0 auto 16px; }

/* progress / strength bar */
.strength-bar{ height:7px; border-radius:5px; background: var(--border); overflow:hidden; display:flex; gap:3px;}
.strength-bar i{ flex:1; background: var(--border); border-radius:3px; transition: background .2s; }
.strength-bar i.on-weak{ background: var(--red); }
.strength-bar i.on-fair{ background: var(--amber); }
.strength-bar i.on-strong{ background: var(--teal); }

/* ===================== Auth pages ===================== */
.auth-wrap{
  min-height:100vh; display:flex;
}
.auth-side{
  flex:1.1; display:flex; flex-direction:column; justify-content:center;
  padding: 60px 64px;
  background:
    radial-gradient(circle at 20% 20%, rgba(232,163,61,.10), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(54,201,154,.08), transparent 45%),
    var(--bg-soft);
  border-left: 1px solid var(--border-soft);
  position:relative; overflow:hidden;
}
.auth-side .stitch{
  position:absolute; inset:24px;
  border: 1.5px dashed rgba(232,163,61,.18);
  border-radius: 26px; pointer-events:none;
}
.auth-side .tagline{ font-size:30px; font-weight:800; max-width:380px; line-height:1.45; }
.auth-side .tagline span{ color: var(--amber-soft); }
.auth-side .features{ margin-top:34px; display:flex; flex-direction:column; gap:14px; }
.auth-side .feature{ display:flex; align-items:center; gap:12px; color: var(--text-dim); font-size:14px;}
.auth-side .feature .patch{ width:36px;height:36px; }
.auth-side .feature .patch svg{ width:17px;height:17px; }

.auth-main{
  flex:1; display:flex; align-items:center; justify-content:center;
  padding: 40px;
}
.auth-box{ width:100%; max-width: 380px; }
.auth-box .brand{ border-bottom:none; padding-bottom:0; justify-content:center; margin-bottom:28px; }
.auth-box h2{ font-size:21px; text-align:center; margin-bottom:6px; }
.auth-box .sub{ text-align:center; font-size:13.5px; margin-bottom:28px; }
.auth-foot{ text-align:center; margin-top:22px; font-size:13.5px; color: var(--text-dim); }

@media (max-width: 920px){
  .auth-side{ display:none; }
}

/* ===================== Responsive app shell ===================== */
@media (max-width: 880px){
  .sidebar{ display:none; }
  .main{ padding: 20px 18px 50px; }
}

/* ===================== Modal (analytics panel) ===================== */
.modal-overlay{
  position: fixed; inset:0; background: rgba(8,10,13,.6);
  display:flex; align-items:center; justify-content:center;
  z-index: 200; opacity:0; pointer-events:none; transition: opacity .18s;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-overlay.show{ opacity:1; pointer-events:auto; }
.modal-box{
  background: var(--surface); border:1px solid var(--border-soft);
  border-radius: var(--radius-lg); width:100%; max-width:560px;
  max-height: 86vh; overflow-y:auto;
  box-shadow: var(--shadow-card);
  transform: translateY(10px); transition: transform .18s;
}
.modal-overlay.show .modal-box{ transform: translateY(0); }
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 18px 22px; border-bottom:1px solid var(--border-soft);
}
.modal-head h3{ margin:0; font-size:16px; }
.modal-close{
  background:none; border:none; color: var(--text-mute); cursor:pointer;
  padding:4px; border-radius:6px; display:flex;
}
.modal-close:hover{ color:var(--text); background: var(--surface-2); }
.modal-pad{ padding: 22px; }

.stat-row{ display:grid; grid-template-columns: repeat(3,1fr); gap:10px; margin-bottom:20px; }
.stat-box{
  background: var(--bg-soft); border:1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding:12px 14px; text-align:center;
}
.stat-box .num{ font-size:20px; font-weight:800; color: var(--amber-soft); font-family: var(--font-mono); }
.stat-box .lbl{ font-size:11.5px; color:var(--text-mute); margin-top:3px; }

.bar-chart{ display:flex; align-items:flex-end; gap:6px; height:120px; padding:0 2px; }
.bar-chart .bar{ flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; height:100%; justify-content:flex-end; }
.bar-chart .bar .fill{ width:100%; background: linear-gradient(180deg, var(--amber-soft), var(--amber)); border-radius:4px 4px 2px 2px; min-height:3px; }
.bar-chart .bar .lbl{ font-size:10px; color:var(--text-mute); }

/* ===================== Public landing page ===================== */
.landing-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 18px 6vw;
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top:0; z-index: 50;
  background: rgba(17,22,28,.85);
  backdrop-filter: blur(8px);
}
.landing-header .nav-links{ display:flex; align-items:center; gap:28px; }
.landing-header .nav-links a{ color: var(--text-dim); font-size:14.5px; font-weight:500; }
.landing-header .nav-links a:hover{ color: var(--text); text-decoration:none; }
.landing-header .actions{ display:flex; align-items:center; gap:10px; }

.hero{
  position:relative; overflow:hidden;
  padding: 90px 6vw 70px;
  text-align:center;
  background:
    radial-gradient(circle at 18% 10%, rgba(232,163,61,.10), transparent 40%),
    radial-gradient(circle at 85% 25%, rgba(54,201,154,.08), transparent 42%);
}
.hero .stitch-frame{
  position:absolute; inset: 18px; border:1.5px dashed rgba(232,163,61,.14);
  border-radius: 30px; pointer-events:none;
}
.hero .eyebrow{
  display:inline-flex; align-items:center; gap:7px;
  margin-bottom: 18px;
}
.hero h1{
  font-size: 42px; max-width: 740px; margin: 0 auto 16px;
  line-height:1.35;
}
.hero h1 span{ color: var(--amber-soft); }
.hero .lead{
  max-width: 540px; margin: 0 auto 30px; font-size:16px;
}
.hero .cta-row{ display:flex; align-items:center; justify-content:center; gap:12px; }

.section{ padding: 64px 6vw; }
.section-head{ text-align:center; max-width:560px; margin:0 auto 38px; }
.section-head h2{ font-size:27px; }
.section-head p{ margin:0; }

.landing-grid{
  display:grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr));
  gap:18px; max-width: 1080px; margin: 0 auto;
}
.feature-card{
  background: var(--surface); border:1px solid var(--border-soft);
  border-radius: var(--radius-md); padding: 22px;
}
.feature-card h4{ font-size:15.5px; margin:14px 0 6px; }
.feature-card p{ font-size:13.5px; margin:0; }

.steps-row{
  display:grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 22px; max-width: 940px; margin: 0 auto;
}
.step{ text-align:center; position:relative; }
.step .num{
  width:38px;height:38px; border-radius:50%; margin:0 auto 14px;
  background: var(--surface-2); border:1px dashed var(--border);
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-mono); font-weight:700; color:var(--amber-soft);
}
.step h4{ font-size:14.5px; margin:0 0 6px; }
.step p{ font-size:13px; margin:0; }

.cta-band{
  margin: 0 6vw 64px; padding: 46px 6vw;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-soft);
  text-align:center;
}
.cta-band h3{ font-size:23px; }
.cta-band p{ max-width:460px; margin:0 auto 22px; }

.landing-footer{
  border-top: 1px solid var(--border-soft);
  padding: 30px 6vw; display:flex; align-items:center; justify-content:space-between;
  color: var(--text-mute); font-size:13px; flex-wrap:wrap; gap:14px;
}
.landing-footer .brand{ border-bottom:none; padding-bottom:0; margin-bottom:0; }
.landing-footer .foot-links{ display:flex; gap:18px; }
.landing-footer .foot-links a{ color: var(--text-mute); font-size:13px; }
.landing-footer .foot-links a:hover{ color: var(--text-dim); }

@media (max-width: 760px){
  .landing-header .nav-links{ display:none; }
  .hero h1{ font-size:30px; }
}

/* print styles used by text-to-pdf page */
@media print{
  body *{ visibility:hidden; }
  #printArea, #printArea *{ visibility:visible; }
  #printArea{
    position:absolute; inset:0; padding: 0;
    background:#fff !important; color:#000 !important;
  }
}

.error-box {
  display: none;
  background: #ffe5e5;
  color: #d8000c;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  border: 1px solid #ffb3b3;
}

.django-messages .alert {
  padding: 10px 15px;
  margin-bottom: 10px;
  border-radius: 6px;
}
.django-messages .alert.success { background: #d4edda; color: #155724; }
.django-messages .alert.dnager   { background: #f8d7da; color: #721c24; }
.django-messages .alert.warning { background: #fff3cd; color: #856404; }
.django-messages .alert.info    { background: #d1ecf1; color: #0c5460; }


.nav-link.active {
    background: #facc15;
    color: #111827;
    font-weight: 600;
}

.nav-link.active svg {
    color: #111827;
}
