/* TENX Catering — брэнд бүк V1-ийн дагуу
   Өнгө: 60% ivory · 30% нил ягаан · 10% магента
   Фонт: гарчиг Montserrat 700/800, бичвэр Inter 400/500
   Градиентийг зөвхөн логонд хэрэглэнэ. */

:root {
  --primary: #5B0463;   /* Гүн нил ягаан */
  --accent:  #CD1F61;   /* Магента — шугам, товч */
  --neutral: #FBF7F4;   /* Цэвэр ivory */
  --ink:     #1D1220;   /* Бичвэрийн хар */
  --white:   #FFFFFF;
  --muted:   #6B6070;
  --line:    #E8E1E6;
  --font-head: "Montserrat", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--neutral);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.55;
}

h1, h2 { font-family: var(--font-head); font-weight: 800; color: var(--primary); margin: 0; }
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 18px; font-weight: 700; line-height: 1.35; }

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* 2 px магента шугам — хуваагч */
.divider { display: block; width: 56px; height: 2px; background: var(--accent); margin: 16px 0 24px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--white);
  border: 0;
  border-radius: 0;
  padding: 12px 22px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: #B51A55; }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-secondary { background: var(--white); color: var(--primary); border: 1px solid var(--primary); padding: 11px 21px; }
.btn-secondary:hover { background: var(--neutral); }
.btn-outline { background: transparent; border: 1px solid rgba(255,255,255,.6); padding: 8px 16px; font-size: 14px; }
.btn-outline:hover { background: rgba(255,255,255,.12); }
.logout-form { margin: 0; }

.alert {
  border-left: 3px solid var(--accent);
  background: #FCEBF1;
  color: #8E1243;
  padding: 10px 14px;
  margin-bottom: 18px;
}
.alert-success { border-left-color: var(--primary); background: #F1E6F2; color: var(--primary); }

/* ---------- Нэвтрэх хуудас ---------- */

.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }

.login-brand {
  background: var(--primary);
  color: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 32px;
}
.login-brand-logo { width: 240px; max-width: 70%; }
.login-brand .divider { margin: 32px auto; width: 120px; }
.login-brand .slogan { font-family: var(--font-head); font-weight: 700; font-size: 26px; line-height: 1.35; margin: 0 0 20px; }
.login-brand .eyebrow { color: rgba(255,255,255,.7); }

.login-form-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
}
.login-form { width: 100%; max-width: 380px; background: var(--white); border: 1px solid var(--line); padding: 36px 32px; }
.login-form-logo { display: none; width: 140px; margin: 0 auto 24px; }
.login-form label { display: block; font-weight: 500; font-size: 14px; margin: 14px 0 6px; }
.login-form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #D9CFD7;
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
}
.login-form input:focus { border-color: var(--primary); }
.login-form .btn { width: 100%; margin-top: 24px; }
.made-by { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.footnote { margin-top: 20px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 800px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-form-logo { display: block; }
  .login-form { padding: 28px 20px; }
}

/* ---------- Самбар ---------- */

.topbar {
  background: var(--primary);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-logo img { display: block; height: 30px; }
.topbar-user { display: flex; align-items: center; gap: 16px; color: rgba(255,255,255,.85); font-size: 14px; }

.shell { display: flex; min-height: calc(100vh - 58px); }

.sidebar {
  flex: 0 0 220px;
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 24px 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-left: 3px solid transparent;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.nav-item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7;
                stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item:hover { background: var(--neutral); color: var(--primary); }
.nav-item.is-active { border-left-color: var(--accent); background: var(--neutral); color: var(--primary); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1040px; margin: 0 auto; padding: 40px 32px 56px; flex: 1; }

.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.stat { background: var(--white); border: 1px solid var(--line); padding: 14px 20px; min-width: 120px; }
.stat-num { display: block; font-family: var(--font-head); font-weight: 800; font-size: 26px; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); }

.posts { display: grid; gap: 16px; }
.post { background: var(--white); border: 1px solid var(--line); border-left: 3px solid var(--primary); padding: 22px 24px; }
.post h2 { margin: 12px 0 8px; }
.post p { margin: 0 0 14px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.post-meta strong { color: var(--ink); font-weight: 500; }
.post-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* Слайдууд: нэг Poster_id-ийн зургууд */
.slides { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin: 0 0 8px; }
.slide {
  flex: 0 0 auto;
  width: 120px;
  height: 150px;              /* 4:5 — сошиал постын харьцаа */
  border: 1px solid var(--line);
  background: var(--neutral);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-decoration: none;
}
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
a.slide:hover, a.slide:focus-visible { border-color: var(--primary); }
.slide-empty-text { display: none; font-size: 12px; color: var(--muted); text-align: center; padding: 8px; }
.slide-empty .slide-empty-text { display: block; }
.slides-count { margin: 0 0 12px !important; font-size: 12px; color: var(--muted); }
.fb-link { color: var(--primary); font-weight: 500; text-decoration: none; }
.fb-link:hover { color: var(--accent); text-decoration: underline; }

.tag { font-size: 12px; font-weight: 500; padding: 3px 10px; border: 1px solid var(--line); color: var(--ink); background: var(--neutral); }
.tag-review    { border-color: var(--accent); color: var(--accent); background: var(--white); }
.tag-approved,
.tag-scheduled { border-color: var(--primary); color: var(--primary); background: var(--white); }
.tag-published { border-color: var(--primary); color: var(--white); background: var(--primary); }
.tag-rejected  { color: var(--muted); text-decoration: line-through; }

/* Захиалгын төлөв */
.tag-pending   { border-color: var(--accent); color: var(--accent); background: var(--white); }
.tag-confirmed { border-color: var(--primary); color: var(--white); background: var(--primary); }
.tag-completed { border-color: var(--primary); color: var(--primary); background: var(--white); }
.tag-cancelled { color: var(--muted); text-decoration: line-through; }

.empty, .muted { color: var(--muted); }

/* Үйлдвэрийн ажлын төлөв, ажилтны идэвх */
.tag-planned     { border-color: var(--primary); color: var(--primary); background: var(--white); }
.tag-in_progress { border-color: var(--accent); color: var(--accent); background: var(--white); }
.tag-done        { border-color: var(--primary); color: var(--white); background: var(--primary); }
.tag-true  { border-color: var(--primary); color: var(--white); background: var(--primary); }
.tag-false { color: var(--muted); }

/* ---------- Гарчиг + товч, хайлт ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--primary); }

.search { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.search input { flex: 1 1 260px; }
.search-clear { font-size: 14px; color: var(--muted); }
.search-summary { margin: -8px 0 16px; font-size: 14px; }

/* ---------- Маягт ---------- */

.search input, .form input:not([type="checkbox"]), .form select, .form textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #D9CFD7;
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
}
.search input:focus, .form input:focus, .form select:focus, .form textarea:focus { border-color: var(--primary); outline: 2px solid var(--accent); outline-offset: 1px; }
.form textarea { resize: vertical; }

.card-form { background: var(--white); border: 1px solid var(--line); padding: 28px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.field label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 6px; }
.field-wide { grid-column: 1 / -1; }
.req { color: var(--accent); }
.checkbox { display: flex !important; align-items: center; gap: 10px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--accent); }
.field-error { margin: 6px 0 0; font-size: 13px; color: #A3174D; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }

.btn-danger { background: #A3174D; }
.btn-danger:hover { background: #86123F; }

/* ---------- Устгахын өмнөх асуулт ---------- */

.confirm { background: var(--white); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 24px 28px; }
.confirm > p { margin: 0 0 18px; }
.confirm-details { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; font-size: 14px; }
.confirm-details dt { color: var(--muted); }
.confirm-details dd { margin: 0; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .card-form, .confirm { padding: 20px 16px; }
}

/* ---------- Хүснэгт ---------- */

.table-wrap { background: var(--white); border: 1px solid var(--line); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--neutral);
  border-bottom: 2px solid var(--primary);
  padding: 12px 16px;
  white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FDFBFA; }
.table strong { font-weight: 500; color: var(--primary); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }
.table .tag { white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions a { color: var(--primary); font-weight: 500; font-size: 14px; margin-left: 14px; }
.row-actions a.danger { color: #A3174D; }

/* ---------- Удахгүй ---------- */

.soon { background: var(--white); border: 1px solid var(--line); padding: 56px 24px; text-align: center; }
.soon h2 { font-size: 24px; font-weight: 800; margin: 20px 0 8px; }
.soon p { margin: 0; color: var(--muted); }

.footer {
  border-top: 1px solid var(--line);
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 32px 32px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Жижиг дэлгэцэнд зүүн цэс дээд талд хэвтээ мөр болно */
@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { flex: none; display: flex; overflow-x: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-item { flex: 1 0 auto; justify-content: center; padding: 12px 14px; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-item.is-active { border-bottom-color: var(--accent); }
  .content { padding: 28px 16px 40px; }
  .footer { padding: 20px 16px 32px; }
}

@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .topbar-email { display: none; }
  h1 { font-size: 24px; }
  .post { padding: 18px 16px; }
}

/* ---------- Цалин (Ажилтан засах) ---------- */

.salary-current { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 6px; }
.salary-current h2 { margin-bottom: 6px; }
.salary-current p { margin: 0; }
.salary-current strong { color: var(--primary); font-weight: 600; }
.field-hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.salary-history { margin-top: 36px; }
.salary-history h2 { margin-bottom: 14px; }
.salary-history .is-current td { background: #FBF3F7; }
.salary-history .up { color: #1E7A4C; font-weight: 500; }
.salary-history .down { color: #A3174D; font-weight: 500; }

/* ---------- Санхүү ---------- */

:root { --good: #1E7A4C; --bad: #B3134F; --bad-bg: #FDEEF3; }

.head-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.fin-hint { font-size: 13px; margin: -6px 0 14px; }
.fin-section { margin-top: 36px; }
.fin-section > h2 { margin-bottom: 14px; }
.fin-sub { font-family: var(--font-body); font-weight: 400; font-size: 14px; }

/* Өөрчлөлтийн сум */
.chg { display: inline-flex; gap: 3px; font-size: 12px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chg-good { color: var(--good); }
.chg-bad  { color: var(--bad); }
.chg-none { color: var(--muted); }
.loss, .loss strong, .table .loss strong { color: var(--bad) !important; }

/* Сарын жагсаалт */
.fin-months tbody tr.row-link { cursor: pointer; }
.fin-months td a { text-decoration: none; }
.fin-months td .tag { margin-left: 8px; }
.fin-months td { line-height: 1.7; }

/* Сар сонгогч */
.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.month-nav input[type="month"] {
  padding: 10px 12px; border: 1px solid #D9CFD7; border-radius: 0; background: var(--white);
  color: var(--ink); font-family: var(--font-body); font-size: 15px; min-width: 0;
}
.month-arrow { padding: 10px 16px; font-size: 16px; line-height: 1; text-decoration: none; }

/* KPI карт */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-top: 3px solid var(--primary); padding: 16px 18px; min-width: 0; }
.kpi-loss { border-top-color: var(--bad); }
.kpi-label { display: block; font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi-value { display: block; margin: 6px 0 4px; font-family: var(--font-head); font-weight: 800; font-size: 22px;
             color: var(--primary); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-loss .kpi-value { color: var(--bad); }
.kpi-change { font-size: 12px; }

/* Ашиг, алдагдлын тайлан */
.pnl td { padding: 10px 16px; }
.pnl td:first-child { width: 60%; }
.pnl .pnl-sub td:first-child { padding-left: 32px; color: var(--muted); }
.pnl .pnl-head td { background: var(--neutral); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pnl .pnl-total td { font-weight: 500; border-top: 1px solid #D9CFD7; }
.pnl .pnl-net td { font-family: var(--font-head); font-weight: 800; font-size: 17px; color: var(--primary);
                   border-top: 2px solid var(--primary); background: #FBF3F7; }
.pnl .pnl-net.loss td { border-top-color: var(--bad); background: var(--bad-bg); }
.pnl tr.loss td { color: var(--bad); }
.pnl tbody tr:hover td { background: inherit; }

/* Графикууд */
.fin-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 36px; }
.fin-panel { background: var(--white); border: 1px solid var(--line); padding: 20px; min-width: 0; }
.fin-panel h2 { margin-bottom: 14px; }
.chart-box { position: relative; width: 100%; }
.chart-donut { height: 220px; }
.legend { list-style: none; margin: 16px 0 0; padding: 0; font-size: 14px; }
.legend li { display: grid; grid-template-columns: 1fr auto 56px; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line);
             font-variant-numeric: tabular-nums; }
.legend li span:not(.legend-name) { text-align: right; white-space: nowrap; }
.legend-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.swatch { display: inline-block; width: 10px; height: 10px; flex: none; }

/* Авлага, гүйлгээ */
.tag-overdue { border-color: var(--bad); color: var(--white); background: var(--bad); }
.tag-income  { border-color: var(--good); color: var(--good); background: var(--white); }
.tag-expense { border-color: var(--accent); color: var(--accent); background: var(--white); }
.table tr.overdue td { background: var(--bad-bg); }
.table tr.overdue td strong { color: var(--bad); }
.table tfoot td { padding: 12px 16px; border-top: 2px solid var(--line); font-weight: 500; background: var(--neutral); }
.amt-in  { color: var(--good); font-weight: 500; }
.amt-out { color: var(--ink); }
.fin-filter, .search select {
  flex: 0 1 200px; padding: 11px 12px; border: 1px solid #D9CFD7; border-radius: 0;
  background: var(--white); color: var(--ink); font-family: var(--font-body); font-size: 15px;
}

/* Орлого / Зардал сонгох товч */
.field-label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 6px; }
.seg { display: inline-flex; border: 1px solid var(--primary); }
.seg-opt { position: relative; margin: 0 !important; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 10px 26px; font-weight: 500; color: var(--primary); background: var(--white); }
.seg-opt + .seg-opt span { border-left: 1px solid var(--primary); }
.seg-opt input:checked + span { background: var(--primary); color: var(--white); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-charts { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .kpi { padding: 14px; }
  .kpi-value { font-size: 19px; }
  .pnl td { padding: 9px 10px; }
  .pnl .pnl-sub td:first-child { padding-left: 18px; }
  .pnl td:first-child { width: auto; }
  .month-nav input[type="month"] { flex: 1; }
  .fin-filter, .search select { flex: 1 1 100%; }

  /* Хүснэгт утсан дээр карт болно (мөр бүр нь «шошго — утга») */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tfoot, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  .table-cards td, .table-cards tfoot td { border: 0; padding: 4px 16px; display: flex; justify-content: space-between;
                    align-items: baseline; gap: 12px; text-align: right; white-space: normal; }
  .table-cards td br { display: none; }
  .table-cards td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left;
                                        margin-right: auto; white-space: nowrap; }
  .table-cards td:first-child { justify-content: flex-start; text-align: left; font-size: 15px; }
  .table-cards td:first-child::before { content: none; }
  .table-cards td:empty, .table-cards .tfoot-label { display: none; }
  .table-cards tfoot tr { padding: 6px 0; }
  .table-cards tfoot td:first-child::before { content: attr(data-label); }
  .table-cards .row-actions { justify-content: flex-end; padding-top: 8px; }
  .table-cards .row-actions a { margin-left: 18px; }
  .table-cards td .muted { margin-left: 6px; }
}
