/* آپلود سنتر — restrained, offline-friendly (no CDN, no web fonts) */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --line: #e3e3de;
  --line-strong: #cfcfc8;
  --text: #1c1c1a;
  --muted: #76766f;
  --ink: #1c1c1a;
  --ink-soft: #3a3a36;
  --ok: #2a6a3f;      --ok-bg: #e9f3ec;
  --warn: #8f5600;    --warn-bg: #fbf0dc;
  --danger: #a3281d;  --danger-bg: #fbe9e6;
  --radius: 10px;
  --font: "Vazirmatn", "IRANSansX", "IRANSans", "Segoe UI", Tahoma, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14.5px; line-height: 1.75;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
small, .muted { color: var(--muted); }
small { font-size: 12.5px; }

/* ── top bar ── */
.topbar {
  display: flex; align-items: center; gap: 18px; height: 52px; padding: 0 22px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: 0; font-size: 15px; }
.spacer { flex: 1; }
.topbar .who small { margin-inline-start: 6px; }
.topbar form { margin: 0; }
button.link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer;
}
button.link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ── layout ── */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 52px); }
.sidebar {
  background: var(--surface); border-inline-end: 1px solid var(--line);
  padding: 18px 12px; position: sticky; top: 52px; align-self: start;
  height: calc(100vh - 52px); overflow-y: auto;
}
.nav-group { margin-bottom: 20px; }
.nav-title { font-size: 11.5px; color: var(--muted); padding: 0 10px 6px; letter-spacing: 0; }
.nav a {
  display: block; padding: 7px 10px; border-radius: 8px; color: var(--ink-soft);
}
.nav a:hover { background: #f1f1ee; text-decoration: none; }
.nav a.active { background: var(--ink); color: #fff; }
main { padding: 28px 32px 60px; max-width: 1100px; width: 100%; }
main.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 20px; }

/* ── surfaces ── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── buttons & fields ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; line-height: 1.5;
}
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; }
.btn.danger { color: var(--danger); border-color: #e4bdb8; }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; font: inherit; color: var(--text);
}
input[type=text], input[type=password], input[type=search], select { height: 40px; }
select { padding-block: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink);
}
input[dir=ltr] { text-align: left; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.search { display: flex; gap: 8px; }
.search input { width: 230px; }

/* ── flash ── */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--surface); }
.flash.success { background: var(--ok-bg); border-color: #c4dfcc; color: var(--ok); }
.flash.error { background: var(--danger-bg); border-color: #efc7c2; color: var(--danger); }

/* ── tables ── */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; font-size: 12.5px; color: var(--muted); background: #fafaf8; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfbf9; }
td.num, th.num { white-space: nowrap; }
td.name { max-width: 380px; }
.fname { display: flex; align-items: center; gap: 12px; }
.fname .t { min-width: 0; }
.fname b { font-weight: 500; overflow-wrap: anywhere; }
.fname small { display: block; }
.ext {
  flex: none; width: 38px; height: 38px; border-radius: 8px; background: #f0f0ec; color: var(--ink-soft);
  display: grid; place-items: center; font: 600 10px/1 ui-monospace, Consolas, monospace; letter-spacing: .02em;
  direction: ltr;
}
td.actions { display: table-cell; }  /* .actions is a flex row for page headers; a table cell must stay a cell */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

/* ── badges ── */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; background: #efefeb; color: var(--ink-soft); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.perm { background: var(--ink); color: #fff; }
.badge.off { background: #efefeb; color: var(--muted); }

/* ── upload ── */
.scope-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.scope-tabs label {
  margin: 0; padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer;
  color: var(--ink-soft); background: var(--surface);
}
.scope-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.scope-tabs input:checked + span { color: #fff; }
.scope-tabs label:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }
.scope-tabs label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 34px 20px; text-align: center;
  color: var(--muted); background: #fcfcfa; cursor: pointer; transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.over { background: #f3f3ef; border-color: var(--ink); color: var(--text); }
.dropzone input { display: none; }
.picked { list-style: none; margin: 12px 0 0; padding: 0; }
.picked li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.picked li:last-child { border-bottom: 0; }
.progress { height: 6px; background: #ecece8; border-radius: 99px; overflow: hidden; margin-top: 14px; display: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .1s; }
.recipients { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin-top: 8px; }
.recipients .grp { font-size: 12px; color: var(--muted); margin: 10px 0 2px; }
.recipients .check { padding: 4px 0; }
.hide { display: none !important; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ── misc ── */
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 16px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.stat b { display: block; font-size: 20px; font-weight: 600; }
.stat span { font-size: 12.5px; color: var(--muted); }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input { width: 180px; padding: 4px 9px; }
.login-title { text-align: center; margin-bottom: 24px; }
.login-title h1 { font-size: 22px; }
.error-page { text-align: center; padding-top: 12vh; }
.error-page .code { font-size: 54px; font-weight: 300; color: var(--line-strong); line-height: 1; }

/* ═════════════════════════ responsive ═════════════════════════ */
.menu-btn, .backdrop, .only-mobile, .only-touch { display: none; }
.menu-btn { width: 40px; height: 40px; margin-inline-start: -8px; border: 0; background: none; border-radius: 8px; cursor: pointer; position: relative; padding: 0; }
.menu-btn span, .menu-btn span::before, .menu-btn span::after { position: absolute; width: 20px; height: 2px; background: var(--ink); border-radius: 2px; }
.menu-btn span { top: 19px; inset-inline-start: 10px; }
.menu-btn span::before, .menu-btn span::after { content: ""; inset-inline-start: 0; }
.menu-btn span::before { top: -6px; }
.menu-btn span::after { top: 6px; }
.menu-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.ltr-val { unicode-bidi: isolate; direction: ltr; }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* tablet and phone: the sidebar becomes a drawer opened by the menu button */
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .only-mobile { display: block; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .top-link { display: none; }
  .layout { display: block; min-height: 0; }
  .sidebar {
    position: fixed; top: 52px; bottom: 0; inset-inline-start: 0; z-index: 30;
    width: min(300px, 86vw); height: auto; align-self: stretch; padding: 16px 12px 28px;
    overscroll-behavior: contain;
    border-inline-end: 0; border-inline-start: 1px solid var(--line);
    box-shadow: -8px 0 24px rgba(0, 0, 0, .12);
    transform: translateX(100%); visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 52px 0 0 0; z-index: 20; background: rgba(0, 0, 0, .35); }
  .nav a { padding: 11px 12px; }
  main { padding: 20px 16px 50px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}

/* phone */
@media (max-width: 700px) {
  body { font-size: 15px; }
  main { padding: 16px 14px 44px; }
  main.auth { margin-top: 7vh; padding: 0 16px; }
  .card { padding: 16px; margin-bottom: 14px; }
  h1 { font-size: 19px; }
  .topbar .who small { display: none; }
  .topbar .who { max-width: 38vw; }

  /* controls: 16px text stops iOS from zooming into fields; taller touch targets */
  input[type=text], input[type=password], input[type=search], select, textarea { font-size: 16px; height: 44px; }
  textarea { height: auto; }
  .btn { min-height: 44px; padding: 8px 16px; justify-content: center; }
  .btn.sm { min-height: 38px; padding: 6px 14px; font-size: 14px; }
  .check { padding: 8px 0; }
  .check input { width: 20px; height: 20px; }
  .recipients { max-height: 48vh; }

  .page-head { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 12px; }
  .page-head > * { min-width: 0; max-width: 100%; }
  .page-head .actions { flex-direction: column; align-items: stretch; }
  .page-head .actions > .btn, .page-head .actions > form { width: 100%; }
  .search { width: 100%; flex-wrap: wrap; }
  .search input { flex: 1; width: auto; min-width: 0; }
  .search select { flex: 1 1 100%; width: 100%; max-width: none; }

  .scope-tabs label { flex: 1 1 calc(50% - 8px); text-align: center; padding: 11px 10px; }
  .dropzone { padding: 26px 14px; }
  .only-desktop { display: none; }
  .only-touch { display: inline; }
  .pager .btn { flex: 1; }
  .stat { padding: 12px 14px; }
  .stat b { font-size: 18px; }

  /* tables turn into stacked cards; the label comes from each cell's data-label */
  .table-wrap { background: none; border: 0; border-radius: 0; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
  .table-wrap tbody tr:hover td { background: none; }
  .table-wrap td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 4px 0; border: 0; text-align: end; }
  .table-wrap td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 13px; text-align: start; }
  .table-wrap td.name { max-width: none; justify-content: flex-start; text-align: start; padding-bottom: 8px; }
  .table-wrap td.title { font-weight: 600; justify-content: flex-start; text-align: start; padding-bottom: 6px; }
  .table-wrap td.actions { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
  .table-wrap td.actions:empty { display: none; }
  .table-wrap td.wide { display: block; }
  .row-actions { justify-content: flex-start; width: 100%; }
  .row-actions > .btn, .row-actions > form { flex: 1 1 auto; }
  .row-actions form .btn { width: 100%; }
  .table-wrap .empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .inline-form { width: 100%; }
  .inline-form input { flex: 1; width: auto; min-width: 0; }
  td.wide .inline-form input { height: 44px; }

  /* help page */
  table.plain, table.plain tbody, table.plain tr, table.plain th, table.plain td { display: block; width: 100%; }
  table.plain th { padding: 10px 0 0; border: 0; }
  table.plain td { padding: 2px 0 10px; }
  .code { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
}

/* ── drive help page ── */
.codebox {
  font: 13.5px/1.6 ui-monospace, Consolas, "Courier New", monospace; background: #f3f3ef; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; overflow-x: auto; user-select: all; white-space: pre-wrap; word-break: break-all;
}
.code { font: 13px ui-monospace, Consolas, monospace; background: #f3f3ef; border-radius: 5px; padding: 1px 6px; user-select: all; display: inline-block; direction: ltr; }
.steps { margin: 0; padding-inline-start: 22px; }
.steps li { margin-bottom: 8px; }
.steps li:last-child { margin-bottom: 0; }
table.plain { width: 100%; }
table.plain th { background: none; color: var(--text); font-weight: 600; font-size: 14px; width: 150px; vertical-align: top; white-space: nowrap; }
table.plain td { color: var(--ink-soft); }
table.plain tr:hover td { background: none; }

/* ── dashboard ── */
.badge.new { background: var(--ink); color: #fff; }
.count-badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-inline-start: 4px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11.5px; font-style: normal; line-height: 20px;
  text-align: center; vertical-align: 1px;
}
.nav a.active .count-badge { background: #fff; color: var(--ink); }
.dash-title { margin: 26px 0 12px; }
.dash-card { padding: 16px 18px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.dash-head h2 { margin: 0; }
.dash-head form { margin: 0; }
.dash-empty { margin: 4px 0 0; }
.dash-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.dash-foot a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .grow b { font-weight: 500; overflow-wrap: anywhere; display: block; }
.rows .grow small { display: block; }
.notify-box { margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 8px; font-size: 13.5px; background: #fafaf8; }
.notify-box p { margin: 0; }
.notify-box .btn { margin-inline-start: 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; min-height: 84px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.tile:hover { border-color: var(--ink); text-decoration: none; }
.tile b { font-size: 22px; font-weight: 600; line-height: 1.4; }
.tile span { font-size: 13px; color: var(--muted); }
.tile.text b { font-weight: 400; color: var(--muted); }

.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.folder {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-soft);
}
.folder:hover { border-color: var(--ink); text-decoration: none; }
.folder svg { flex: none; color: var(--ink-soft); }
.folder .t { min-width: 0; flex: 1; }
.folder .t b { display: block; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.folder .t small { display: block; }
.folder.mine { border-color: var(--line-strong); box-shadow: inset 3px 0 0 var(--ink); }
.folder.public svg { color: var(--ok); }
.folder > .badge { align-self: flex-start; }

@media (max-width: 700px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .folders { grid-template-columns: 1fr; }
  .rows li { flex-wrap: wrap; }
  .rows .grow { flex-basis: calc(100% - 60px); }
  .rows li .btn, .rows li .badge { margin-inline-start: 52px; }
  .notify-box .btn { margin: 8px 0 0; display: inline-flex; }
}
