@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
  --navy: #12263F;
  --navy-2: #1B3A5C;
  --navy-soft: #223C58;
  --bg: #F3F6FA;
  --card: #FFFFFF;
  --accent-orange: #EE8A3E;
  --accent-purple: #8B62C9;
  --accent-blue: #2E8FCB;
  --success: #279B6E;
  --success-bg: #E7F6F0;
  --warning: #DFA22A;
  --warning-bg: #FBF3E1;
  --danger: #D6484A;
  --danger-bg: #FBEAEA;
  --text: #1D2733;
  --text-muted: #6D7C8D;
  --border: #E4E9F0;
  --radius: 14px;
  --gradient: linear-gradient(90deg, var(--accent-orange), var(--accent-purple), var(--accent-blue));
  --shadow: 0 2px 14px rgba(18, 38, 63, 0.06);
  --shadow-lift: 0 8px 24px rgba(18, 38, 63, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-feature-settings: 'ss01' on;
  direction: rtl;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }

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

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { height: 34px; }
.sidebar-brand span { font-weight: 700; font-size: 14.5px; line-height: 1.4; }

.sidebar-flow {
  height: 3px;
  background: var(--gradient);
}

.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar-nav .group-label {
  font-size: 11.5px; color: rgba(255,255,255,.45);
  padding: 14px 10px 6px; letter-spacing: .5px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  color: rgba(255,255,255,.82);
  font-size: 14px; font-weight: 500;
  margin-bottom: 3px;
  transition: background .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active {
  background: linear-gradient(90deg, rgba(238,138,62,.22), rgba(139,98,201,.18));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent-orange);
}
.sidebar-nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }

.sidebar-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
}
.sidebar-footer .who { color: rgba(255,255,255,.9); font-weight: 600; margin-bottom: 8px; }
.sidebar-footer a.logout { color: #ffb4b4; display: flex; align-items: center; gap: 6px; }

.main {
  margin-right: 250px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .breadcrumb { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; }

.content { padding: 22px 26px 60px; }

/* ===================== Cards ===================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}
.card-title {
  font-size: 15.5px; font-weight: 700; margin: 0 0 14px;
  display: flex; align-items: center; justify-content: space-between;
}

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr !important; }
  .card { padding: 16px; }
  .stat-card .num { font-size: 25px; }
  table { font-size: 12.8px; }
  th, td { padding: 9px 8px; }
  .btn { padding: 9px 14px; }
  .login-card { padding: 30px 22px; }
  h1, .topbar h1 { font-size: 16px; }
  .stage-flow .name { font-size: 10.5px; }
  .stage-flow .dot { width: 13px; height: 13px; }
  .content { padding-left: 12px; padding-right: 12px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}

/* Stat cards */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px;
  background: var(--bar-color, var(--accent-blue));
}
.stat-card .num { font-size: 30px; font-weight: 800; color: var(--navy); }
.stat-card .label { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

/* ===================== Stage flow (signature element) ===================== */
.stage-flow {
  display: flex; align-items: center; gap: 0;
  padding: 6px 4px;
}
.stage-flow .stage {
  flex: 1; text-align: center; position: relative; padding-top: 26px;
}
.stage-flow .dot {
  position: absolute; top: 0; right: 50%; transform: translateX(50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: #E4E9F0; border: 3px solid var(--card);
  box-shadow: 0 0 0 2px #E4E9F0;
  z-index: 2;
}
.stage-flow .stage.done .dot { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.stage-flow .stage.current .dot { background: var(--accent-orange); box-shadow: 0 0 0 4px rgba(238,138,62,.22); }
.stage-flow .line {
  position: absolute; top: 8px; right: -50%; width: 100%; height: 3px;
  background: var(--border); z-index: 1;
}
.stage-flow .stage:first-child .line { display: none; }
.stage-flow .stage.done .line, .stage-flow .stage.current .line { background: var(--gradient); }
.stage-flow .name { font-size: 12.5px; margin-top: 6px; color: var(--text-muted); font-weight: 600; }
.stage-flow .stage.current .name, .stage-flow .stage.done .name { color: var(--text); }

/* ===================== Table ===================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.8px; }
th, td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; font-size: 12.8px; background: #FAFBFD; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFD; }

/* ===================== Badges ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 100px; font-size: 12px; font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: #EEF1F5; color: var(--text-muted); }
.badge-info { background: #E9F2FA; color: var(--accent-blue); }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 10px 18px; border-radius: 10px; border: none; cursor: pointer;
  font-size: 13.8px; font-weight: 600; transition: all .15s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-accent { background: var(--accent-orange); color: #fff; }
.btn-accent:hover { filter: brightness(1.06); }
.btn-outline { background: #fff; color: var(--navy); border: 1px solid var(--border); }
.btn-outline:hover { background: #F5F7FA; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 12.8px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ===================== Forms ===================== */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13.3px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--border);
  font-family: inherit; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(46,143,203,.14); }
textarea { min-height: 90px; resize: vertical; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ===================== Login page ===================== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  background-image: radial-gradient(circle at 20% 15%, rgba(238,138,62,.18), transparent 40%),
                     radial-gradient(circle at 85% 85%, rgba(46,143,203,.2), transparent 45%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 20px; padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lift); text-align: center;
}
.login-card img { height: 52px; margin-bottom: 6px; }
.login-card h2 { font-size: 17px; margin: 4px 0 24px; color: var(--navy); }
.login-card .form-group { text-align: right; }
.login-flow { height: 4px; border-radius: 100px; background: var(--gradient); margin-bottom: 22px; }
.login-footer { margin-top: 20px; text-align: center; font-size: 12.5px; color: rgba(255,255,255,.55); }
.login-footer a { color: rgba(255,255,255,.85); text-decoration: underline; }

/* ===================== Alerts ===================== */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 13.8px; font-weight: 500; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }

/* ===================== Misc ===================== */
.muted { color: var(--text-muted); }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; }
.mb-0 { margin-bottom: 0; } .mt-14 { margin-top: 14px; } .mb-14 { margin-bottom: 14px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; opacity: .4; margin-bottom: 10px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gradient); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}

.work-entry-row { display: grid; grid-template-columns: 1.6fr 0.8fr 0.9fr auto; gap: 10px; align-items: end; margin-bottom: 10px; }
@media (max-width: 720px) { .work-entry-row { grid-template-columns: 1fr !important; } .work-entry-row > div { width: 100%; } }

.timeline { border-right: 2px solid var(--border); padding-right: 18px; margin-right: 6px; }
.timeline .item { position: relative; padding-bottom: 18px; }
.timeline .item::before {
  content: ''; position: absolute; right: -23px; top: 3px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent-blue); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--border);
}
.timeline .item .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.file-thumb { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fafbfd; text-align: center; }
.file-thumb img { width: 100%; height: 90px; object-fit: cover; display: block; }
.file-thumb .file-icon { height: 90px; display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--text-muted); }
.file-thumb .cap { font-size: 11px; padding: 6px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== Mobile ===================== */
.bottom-nav { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(100%); width: 78%; max-width: 300px; }
  .sidebar.open { transform: translateX(0); box-shadow: -10px 0 40px rgba(0,0,0,.25); }
  .main { margin-right: 0; }
  .menu-toggle { display: flex; align-items:center; justify-content:center; width: 38px; height: 38px; }
  .content { padding: 16px 14px 90px; }
  .topbar { padding: 12px 14px; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(10,18,30,.45); z-index: 90; }
  .sidebar-overlay.show { display: block; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; right: 0; left: 0; z-index: 80;
    background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,.06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; text-align: center; font-size: 11px; color: var(--text-muted); padding: 6px 2px; }
  .bottom-nav a.active { color: var(--accent-orange); }
  .bottom-nav svg { width: 20px; height: 20px; display: block; margin: 0 auto 3px; }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print { display: none !important; }
  .main { margin-right: 0; }
}
