* { box-sizing: border-box; font-family: Tahoma, Arial, sans-serif; }
body { margin: 0; background: #f4f6f8; color: #222; }
.hidden { display: none !important; }

/* Login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #eef2f7; }
.login-box { background: white; padding: 30px; border-radius: 10px; width: 320px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.login-box h2 { margin-top: 0; text-align: center; color: #1f6feb; font-size: 18px; }
.login-box label { display: block; margin: 12px 0 4px; font-size: 13px; color: #555; }
.login-box input { width: 100%; padding: 9px; border: 1px solid #ccc; border-radius: 6px; }
.login-box button { width: 100%; margin-top: 18px; padding: 10px; background: #1f6feb; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 15px; }
.login-box .error { color: #b42318; font-size: 13px; margin: 8px 0 0; }

/* Header */
header { background: #1f6feb; color: white; padding: 14px 24px; }
.header-top { display: flex; align-items: center; justify-content: space-between; }
header h1 { margin: 0; font-size: 19px; cursor: pointer; }
.userbar { display: flex; align-items: center; gap: 10px; color: #d9e8ff; font-size: 13px; }
.userbar button { background: rgba(255,255,255,0.15); color: white; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.icon-btn { position: relative; font-size: 15px; }
.badge-count { position: absolute; top: -6px; left: -6px; background: #e53935; color: white; font-size: 10px; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }

nav#moduleNav { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; background: rgba(255,255,255,0.12); padding: 6px; border-radius: 12px; }
nav .modnav {
  display: flex; align-items: center; gap: 7px;
  background: transparent; border: none; color: #dce9ff;
  padding: 10px 18px; cursor: pointer; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; transition: background .15s, color .15s, transform .1s;
}
nav .modnav-icon { font-size: 15px; }
nav .modnav:hover { background: rgba(255,255,255,0.14); color: white; }
nav .modnav.active { background: white; color: #1f6feb; font-weight: 700; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
nav .modnav.active:hover { background: white; }

.module-title-bar { max-width: 1250px; margin: 18px auto 0; padding: 0 20px; display: flex; align-items: center; gap: 10px; }
.module-title-bar span { font-size: 22px; }
.module-title-bar h2 { margin: 0; color: #1f2937; font-size: 20px; }

main { padding: 20px; max-width: 1250px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.section-title { color: #333; }

/* Launcher */
.launcher-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.launcher-card { background: white; border-radius: 10px; padding: 22px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); cursor: pointer; transition: transform .1s; }
.launcher-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.12); }
.launcher-card-icon { font-size: 30px; margin-bottom: 6px; }
.launcher-card h3 { margin: 0 0 8px; color: #1f6feb; }
.launcher-card p { margin: 0; color: #666; font-size: 13px; }

/* Toolbar / tables */
.toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.toolbar.wrap { justify-content: flex-start; }
.toolbar input, .toolbar select { padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; }
.toolbar input { flex: 1; min-width: 160px; }
.toolbar button { background: #1f6feb; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.toolbar button.secondary { background: #6b7280; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); min-width: 700px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid #eee; font-size: 13px; white-space: nowrap; }
th { background: #eef2f7; }
tr:hover td { background: #f9fbff; }
.linklike { color: #1f6feb; cursor: pointer; }

/* Progress bar */
.progress-wrap { background: #eee; border-radius: 20px; width: 90px; height: 8px; overflow: hidden; display: inline-block; vertical-align: middle; }
.progress-bar { background: #1f6feb; height: 100%; }

/* Modal */
#modalOverlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
#modalOverlay.hidden { display: none; }
#modalBox { background: white; padding: 20px; border-radius: 10px; width: 420px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
#modalBox h3 { margin-top: 0; }
#modalBox label { display: block; margin: 10px 0 4px; font-size: 13px; color: #555; }
#modalBox input, #modalBox select, #modalBox textarea { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px; }
#modalBox .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#modalBox .actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }
#modalBox button { padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; }
#modalBox .save { background: #1f6feb; color: white; }
#modalBox .cancel { background: #eee; }
#modalBox fieldset { border: 1px solid #eee; border-radius: 6px; margin-top: 14px; }
#modalBox legend { padding: 0 6px; font-size: 12px; color: #888; }

/* Notifications */
#notifOverlay { position: fixed; inset: 0; z-index: 40; }
#notifOverlay.hidden { display: none; }
#notifBox { position: absolute; top: 60px; left: 24px; background: white; width: 320px; max-height: 400px; overflow-y: auto; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid #eee; }
.notif-header h3 { margin: 0; font-size: 14px; }
.notif-header .linklike { font-size: 11px; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid #f2f2f2; font-size: 13px; }
.notif-item.unread { background: #f0f6ff; }
.notif-item .time { color: #999; font-size: 11px; margin-top: 4px; }

/* Badges */
.badge { padding: 3px 8px; border-radius: 20px; font-size: 12px; }
.badge.open { background: #fde2e2; color: #b42318; }
.badge.progress { background: #fef3c7; color: #92400e; }
.badge.closed { background: #d1fae5; color: #027a48; }
.badge.gray { background: #e5e7eb; color: #374151; }

/* Access level select in admin table */
.access-select { padding: 4px 6px; border-radius: 4px; border: 1px solid #ccc; font-size: 12px; }

/* Wide modal variant for reports and module-1 form (avoids horizontal scrolling) */
#modalBox.wide { width: 900px; max-width: 96vw; }
#modalBox.medium { width: 600px; max-width: 96vw; }

/* Report tables inside modals */
.report-table { width: 100%; font-size: 12.5px; border-collapse: collapse; margin-top: 8px; }
.report-table th, .report-table td { padding: 8px 10px; border-bottom: 1px solid #eee; text-align: right; }
.report-table th { background: #f4f6f8; }

/* Simple bar chart (no external library) */
.chart-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; }
.chart-label { width: 150px; flex-shrink: 0; color: #444; }
.chart-track { flex: 1; background: #eef1f5; border-radius: 6px; height: 16px; overflow: hidden; }
.chart-fill { height: 100%; background: #1f6feb; border-radius: 6px; display: flex; align-items: center; }
.chart-fill.green { background: #16a34a; }
.chart-fill.orange { background: #f59e0b; }
.chart-fill.red { background: #e11d48; }
.chart-value { width: 46px; text-align: left; font-weight: 600; color: #333; }
.chart-section-title { margin: 18px 0 4px; font-size: 13px; font-weight: 700; color: #1f2937; }

/* Table with more breathing room (module 1) */
#m1Table th, #m1Table td { padding: 12px 14px; }

/* Catalog management list rows with edit/delete */
.cat-item-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid #f2f2f2; font-size: 13px; }
.cat-item-row .cat-actions { display: flex; gap: 10px; }

/* Dashboard KPI cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 14px 0; }
.stat-card { background: white; border-radius: 10px; padding: 16px 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); border-right: 4px solid #1f6feb; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; color: #1f2937; }
.stat-card .stat-label { font-size: 12.5px; color: #6b7280; margin-top: 4px; }
.stat-card.orange { border-right-color: #f59e0b; }
.stat-card.green { border-right-color: #16a34a; }
.stat-card.red { border-right-color: #e11d48; }

.dashboard-charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 6px; }
.dashboard-panel { background: white; border-radius: 10px; padding: 16px 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); }
.dashboard-panel h3 { margin: 0 0 10px; font-size: 14px; color: #1f2937; }
.dashboard-panel .panel-icon { margin-left: 6px; }

/* Dashboard KPI cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 14px; }
.stat-card { background: white; border-radius: 10px; padding: 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); text-align: center; }
.stat-icon { font-size: 24px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; color: #1f2937; }
.stat-label { font-size: 12px; color: #888; margin-top: 4px; }

/* Dashboard monthly trend charts */
.dashboard-charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 18px; }
.dashboard-chart-box { background: white; border-radius: 10px; padding: 16px 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.vbar-chart { display: flex; align-items: flex-end; gap: 10px; height: 130px; margin-top: 12px; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.vbar-value { font-size: 11px; color: #333; margin-bottom: 3px; font-weight: 600; }
.vbar-fill { width: 60%; background: linear-gradient(180deg, #4f8cf7, #1f6feb); border-radius: 5px 5px 0 0; min-height: 3px; transition: height .3s; }
.vbar-label { font-size: 10.5px; color: #888; margin-top: 6px; }

/* کارت‌های قابل کلیک در داشبورد (باز شدن جزئیات) */
.clickable-stat { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.clickable-stat:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

/* فیلترهای مودال جزئیات داشبورد */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 14px; margin-top: 6px; }
.filter-grid label { display: block; margin: 0 0 4px; font-size: 12px; color: #555; }
.filter-grid input, .filter-grid select { width: 100%; padding: 7px 9px; border: 1px solid #ccc; border-radius: 6px; }
.checkline { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; color: #444; }
.checkline input { width: auto; }
.dd-count { font-size: 12px; color: #888; margin-top: 8px; }
#dd_resultsWrap { margin-top: 12px; }

/* تنظیمات سیستم (پنل مدیریت) */
.settings-box { background: white; border-radius: 10px; padding: 18px 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); max-width: 700px; margin-top: 14px; }
.settings-box label { display: block; margin: 12px 0 4px; font-size: 13px; color: #555; }
.settings-box input { width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; }
.settings-box .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.save-settings-btn { margin-top: 18px; background: #1f6feb; color: white; border: none; padding: 9px 18px; border-radius: 6px; cursor: pointer; }

/* ==================== واکنش‌گرا برای موبایل و تبلت ==================== */
@media (max-width: 900px) {
  main { padding: 12px; }
  header { padding: 10px 12px; }
  header h1 { font-size: 16px; }
  .userbar { font-size: 12px; gap: 6px; }
  .userbar button { padding: 5px 9px; font-size: 12px; }

  nav#moduleNav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  nav .modnav { padding: 9px 12px; font-size: 12.5px; white-space: nowrap; flex-shrink: 0; }

  .module-title-bar { padding: 0 4px; }
  .module-title-bar h2 { font-size: 17px; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select, .toolbar button { width: 100%; min-width: 0; }

  .settings-box .row2 { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr; }

  #modalBox { width: 96vw !important; padding: 14px; }
  #modalBox .row2 { grid-template-columns: 1fr; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 11px; }

  .launcher-grid { grid-template-columns: 1fr; }
  .dashboard-charts-grid { grid-template-columns: 1fr; }

  .chart-label { width: 90px; font-size: 11px; }

  table { min-width: 600px; }
}

@media (max-width: 480px) {
  header h1 { font-size: 14px; }
  #whoami { display: none; }
  .stat-grid { grid-template-columns: 1fr; }
  .login-box { width: 92vw; padding: 22px; }
}
