:root {
  --ink: #1c2b3a;
  --ink-soft: #5b6b7c;
  --navy: #16324f;
  --navy-deep: #0f2438;
  --brass: #b98a2f;
  --brass-soft: #e8d9b8;
  --paper: #f6f4ef;
  --card: #ffffff;
  --line: #e4dfd4;
  --ok: #2e7d4f;
  --warn: #b26a00;
  --bad: #b3372f;
  --info: #2f5d8a;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Cairo', sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(22,50,79,0.05) 1px, transparent 0);
  background-size: 26px 26px;
}
#app { position: relative; z-index: 1; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ---------- header ---------- */
.topbar {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  padding: 0;
  box-shadow: 0 2px 14px rgba(15,36,56,.25);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff;
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.15rem; color: var(--brass-soft);
}
.brand-name { font-weight: 800; font-size: 1.25rem; letter-spacing: .2px; }
.brand-sub { font-size: .78rem; color: rgba(255,255,255,.65); font-weight: 500; }
.topbar-spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem; color: rgba(255,255,255,.85);
}
.user-chip .role-badge {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  padding: 1px 10px; border-radius: 20px; font-size: .75rem;
}
.btn-logout {
  background: transparent; color: rgba(255,255,255,.8);
  border: 1px solid rgba(255,255,255,.3); border-radius: 9px;
  padding: 5px 14px; font-size: .82rem; font-weight: 600;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- layout ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 26px 20px 70px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 1.45rem; font-weight: 800; color: var(--navy); }
.page-head .spacer { flex: 1; }
.crumb { font-size: .85rem; color: var(--ink-soft); margin-bottom: 6px; }
.crumb a { color: var(--info); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--card); width: 100%; max-width: 410px;
  border-radius: 18px; border: 1px solid var(--line);
  box-shadow: 0 14px 44px rgba(15,36,56,.10);
  overflow: hidden;
}
.login-head {
  background: linear-gradient(160deg, var(--navy), var(--navy-deep));
  color: #fff; text-align: center; padding: 30px 24px 24px;
}
.login-head .brand-mark { margin: 0 auto 12px; width: 54px; height: 54px; font-size: 1.4rem; border-radius: 14px; }
.login-head h1 { font-size: 1.35rem; font-weight: 800; }
.login-head p { font-size: .85rem; color: rgba(255,255,255,.7); margin-top: 4px; }
.login-body { padding: 26px 26px 30px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fdfcf9; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(22,50,79,.10);
  background: #fff;
}
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: .75rem; color: var(--ink-soft); margin-top: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; border: 1.5px solid transparent;
  padding: 10px 22px; font-size: .95rem; font-weight: 700;
  transition: filter .15s, background .15s, border-color .15s;
  text-decoration: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: #efece4; }
.btn-danger { background: transparent; color: var(--bad); border-color: #e5c3c0; }
.btn-danger:hover { background: #f9eeed; }
.btn-sm { padding: 6px 14px; font-size: .82rem; border-radius: 8px; }

/* ---------- home modules ---------- */
.home-hello { margin-bottom: 22px; }
.home-hello h2 { font-size: 1.3rem; font-weight: 800; color: var(--navy); }
.home-hello p { color: var(--ink-soft); font-size: .9rem; }
.modules-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.module-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 22px; text-decoration: none; color: var(--ink);
  display: block; position: relative;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.module-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(15,36,56,.10); border-color: #cfc7b4; }
.module-icon {
  width: 50px; height: 50px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.module-icon svg { width: 26px; height: 26px; }
.module-card h3 { font-size: 1.1rem; font-weight: 800; color: var(--navy); margin-bottom: 5px; }
.module-card p { font-size: .84rem; color: var(--ink-soft); }
.module-tag {
  position: absolute; top: 16px; inset-inline-start: auto; inset-inline-end: 16px;
  font-size: .7rem; font-weight: 700; padding: 2px 10px; border-radius: 14px;
}
.tag-live { background: #e4f2e9; color: var(--ok); }
.tag-soon { background: #f2ede1; color: var(--ink-soft); }
.soon-grid { margin-top: 26px; }
.soon-title { font-size: .95rem; font-weight: 800; color: var(--ink-soft); margin-bottom: 12px; }
.soon-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.soon-chip {
  background: #efece4; border: 1px dashed #cfc7b4; color: var(--ink-soft);
  border-radius: 20px; padding: 4px 14px; font-size: .8rem; font-weight: 600;
}

/* ---------- stats ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-num { font-size: 1.7rem; font-weight: 800; color: var(--navy); line-height: 1.2; }
.stat-num.bad { color: var(--bad); }
.stat-label { font-size: .8rem; color: var(--ink-soft); font-weight: 600; }

/* ---------- table ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar input[type=search], .toolbar select {
  padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 9px;
  background: #fff; font-size: .88rem;
}
.toolbar input[type=search] { flex: 1; min-width: 160px; }
.table-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: #f1ede3; color: var(--navy); font-weight: 800; font-size: .8rem;
  text-align: start; padding: 11px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid #efece4; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: #f8f6f0; }
.capa-num { font-weight: 800; color: var(--info); white-space: nowrap; }
.capa-title-cell { max-width: 260px; }
.capa-title-cell .t { font-weight: 700; display: block; }
.capa-title-cell .d { font-size: .76rem; color: var(--ink-soft); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-block; padding: 2px 11px; border-radius: 14px;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.badge-open { background: #e3ecf5; color: var(--info); }
.badge-progress { background: #f7ecd4; color: var(--warn); }
.badge-verify { background: #efe6f4; color: #6d3f96; }
.badge-closed { background: #e4f2e9; color: var(--ok); }
.badge-kind-c { background: #f3e6e4; color: var(--bad); }
.badge-kind-p { background: #e4eff0; color: #1f6e73; }
.overdue { color: var(--bad); font-weight: 700; }
.empty-state { text-align: center; padding: 54px 20px; color: var(--ink-soft); }
.empty-state .big { font-size: 2.4rem; margin-bottom: 10px; }

/* ---------- detail / form ---------- */
.form-card, .detail-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; margin-bottom: 18px;
}
.detail-card h3, .form-card h3 {
  font-size: .95rem; font-weight: 800; color: var(--navy);
  padding-bottom: 10px; margin-bottom: 16px; border-bottom: 2px solid #f1ede3;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.detail-head {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 6px;
}
.detail-head h2 { font-size: 1.2rem; font-weight: 800; color: var(--navy); flex: 1; min-width: 200px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px 20px; margin-bottom: 4px; }
.meta-item .k { font-size: .74rem; color: var(--ink-soft); font-weight: 700; }
.meta-item .v { font-size: .92rem; font-weight: 600; }
.section-text { margin-top: 14px; }
.section-text .k { font-size: .8rem; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.section-text .v {
  background: #faf8f3; border: 1px solid #efece4; border-radius: 10px;
  padding: 10px 14px; font-size: .9rem; white-space: pre-wrap; min-height: 20px;
}
.status-flow { display: flex; gap: 0; margin: 18px 0; flex-wrap: wrap; }
.status-step {
  flex: 1; min-width: 110px; text-align: center; font-size: .76rem; font-weight: 700;
  padding: 8px 6px; color: var(--ink-soft);
  background: #f1ede3; position: relative;
}
.status-step:first-child { border-start-start-radius: 9px; border-end-start-radius: 9px; }
.status-step:last-child { border-start-end-radius: 9px; border-end-end-radius: 9px; }
.status-step.active { background: var(--navy); color: #fff; }
.status-step.done { background: #d9e7de; color: var(--ok); }
.log-list { list-style: none; }
.log-item {
  border-inline-start: 3px solid var(--brass); background: #faf8f3;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; font-size: .86rem;
}
.log-item .when { font-size: .74rem; color: var(--ink-soft); }
.log-item .who { font-weight: 700; color: var(--navy); }
.log-item .change { color: var(--ink-soft); }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- messages ---------- */
.alert {
  border-radius: 10px; padding: 11px 15px; font-size: .87rem; font-weight: 600;
  margin-bottom: 16px;
}
.alert-err { background: #f9eeed; color: var(--bad); border: 1px solid #e5c3c0; }
.alert-ok { background: #e9f4ec; color: var(--ok); border: 1px solid #c4e0cd; }
.loading-wrap { text-align: center; padding: 70px 20px; color: var(--ink-soft); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 12px;
  border: 3.5px solid #e4dfd4; border-top-color: var(--navy);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link-quiet { background: none; border: none; color: var(--info); font-size: .82rem; font-weight: 600; padding: 0; }
.link-quiet:hover { text-decoration: underline; }
.text-center { text-align: center; }
.mt { margin-top: 14px; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .page { padding: 18px 14px 60px; }
  .topbar-inner { padding: 12px 14px; }
  .user-chip .email { display: none; }
  thead th:nth-child(4), tbody td:nth-child(4) { display: none; }
  .form-card, .detail-card { padding: 18px 15px; }
  .status-step { min-width: 70px; font-size: .68rem; }
}

/* ---------- inline modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15,36,56,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: #fff; border-radius: 16px; padding: 22px 24px;
  max-width: 460px; width: 100%;
  box-shadow: 0 20px 60px rgba(15,36,56,.3);
}
.modal-title { font-size: 1.05rem; font-weight: 800; color: var(--navy); margin-bottom: 12px; }
.modal-body { font-size: .9rem; color: var(--ink); margin-bottom: 6px; }
.modal-box textarea {
  width: 100%; min-height: 90px; padding: 10px 13px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: #fdfcf9; font-size: .95rem; resize: vertical;
}
.modal-box textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(22,50,79,.10); background: #fff; }
.modal-err {
  background: #f9eeed; color: var(--bad); border: 1px solid #e5c3c0;
  border-radius: 9px; padding: 8px 12px; font-size: .82rem; font-weight: 600; margin-top: 10px;
}
