/* OPER v2 webapp — стиль минимальный, читаемый */

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: #f7f8fa;
  color: #1f2937;
}

.container { max-width: 1400px; margin: 16px auto; padding: 0 16px; }

/* nav */
.topnav {
  background: #1f2937;
  color: white;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 24px;
  border-bottom: 1px solid #111827;
}
.topnav .brand { color: white; text-decoration: none; font-weight: bold; padding: 12px 0; font-size: 16px; }
.topnav nav { flex: 1; display: flex; gap: 16px; }
.topnav nav a { color: #d1d5db; text-decoration: none; padding: 12px 0; }
.topnav nav a:hover { color: white; }
.topnav .navdrop { position: relative; display: flex; align-items: center; }
.topnav .navdrop .navdrop-top { display: inline-flex; align-items: center; }
.topnav .navdrop:hover .navdrop-top { color: white; }
.topnav .navdrop-menu { position: absolute; left: 0; top: 100%; min-width: 170px; display: none;
  background: #1f2937; border: 1px solid #111827; border-top: none; border-radius: 0 0 6px 6px;
  padding: 4px 0; z-index: 50; }
.topnav .navdrop:hover .navdrop-menu { display: block; }
.topnav .navdrop-menu a { display: block; color: #d1d5db; padding: 8px 16px; }
.topnav .navdrop-menu a:hover { background: #374151; color: white; }
.topnav .user { display: flex; gap: 12px; align-items: center; color: #d1d5db; }
.topnav .user a { color: #fca5a5; text-decoration: none; }

footer { text-align: center; color: #9ca3af; padding: 24px; }

h1 { font-size: 22px; margin: 0 0 16px; }
h3 { font-size: 16px; margin: 24px 0 8px; }
.muted { color: #6b7280; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* row-between, cards */
.row-between { display: flex; justify-content: space-between; align-items: center; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: white; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 16px; text-decoration: none; color: #1f2937;
}
.card:hover { border-color: #2563eb; }
.card h3 { margin: 0 0 8px; }
.card .big { font-size: 28px; font-weight: 600; margin: 8px 0; color: #2563eb; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; margin: 16px 0; }
.kv { background: white; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 12px; }
.kv .k { font-size: 12px; color: #6b7280; }
.kv .v { font-size: 14px; }

/* tables */
table.data {
  width: 100%; border-collapse: collapse; background: white;
  border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden;
}
table.data th, table.data td {
  padding: 8px 12px; text-align: left; border-bottom: 1px solid #f3f4f6;
}
table.data th { background: #f9fafb; font-weight: 600; font-size: 12px;
                text-transform: uppercase; color: #6b7280; letter-spacing: 0.5px; }
table.data tr:hover td { background: #f9fafb; }
table.data tr.neg td { color: #b91c1c; }
table.data tr.pos { /* no special */ }

/* forms */
.form { display: grid; gap: 12px; max-width: 600px; background: white;
        border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; }
.form label { display: grid; gap: 4px; font-size: 12px; color: #6b7280; }
.form input, .form select, .form textarea {
  font: inherit; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 4px; color: #1f2937;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: #2563eb;
}
.form-actions { display: flex; gap: 8px; margin-top: 8px; }

.form-inline { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; align-items: center; }
.form-inline input { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 4px; }

/* buttons */
.btn, button {
  display: inline-block; padding: 8px 16px;
  background: white; color: #1f2937;
  border: 1px solid #d1d5db; border-radius: 4px;
  text-decoration: none; cursor: pointer; font: inherit;
}
.btn:hover, button:hover { border-color: #2563eb; color: #2563eb; }
.btn.primary, button.primary {
  background: #2563eb; color: white; border-color: #2563eb;
}
.btn.primary:hover, button.primary:hover { background: #1d4ed8; color: white; }
.btn-link {
  background: none; border: none; padding: 4px 8px; cursor: pointer; color: #6b7280;
}
.btn-link.danger { color: #b91c1c; }

/* errors */
.err {
  background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b;
  padding: 8px 12px; border-radius: 4px; margin-bottom: 12px;
}
.err-inline { color: #991b1b; }
.ok-msg {
  background: #d1fae5; border: 1px solid #6ee7b7; color: #065f46;
  padding: 8px 12px; border-radius: 4px; margin-bottom: 12px;
}
.muted-light { color: #9ca3af; }
tr.muted td { color: #9ca3af; }
.topnav .user a { color: #d1d5db; text-decoration: none; }
.topnav .user a:hover { color: white; }

/* dashboards */
.period-switch { margin: 16px 0; padding: 8px 12px; background: white;
                 border: 1px solid #e5e7eb; border-radius: 6px;
                 display: flex; gap: 12px; align-items: center; }
.period-switch a { color: #2563eb; text-decoration: none; padding: 2px 8px; border-radius: 4px; }
.period-switch a:hover { background: #f3f4f6; }
.period-switch .period-current { background: #2563eb; color: white; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.neg-cell { color: #b91c1c; }

/* sub-nav (для разделов с несколькими страницами) */
.subnav { display: flex; gap: 16px; }
.subnav a { color: #6b7280; text-decoration: none; padding: 4px 8px; border-radius: 4px; font-size: 13px; }
.subnav a:hover { background: #f3f4f6; }
.subnav a.active { background: #2563eb; color: white; }

/* «ключ → значение» в одну строку (для шапок страниц артикулов) */
.kv-row { background: white; padding: 8px 12px; border: 1px solid #e5e7eb;
          border-radius: 6px; margin: 8px 0; display: flex; gap: 16px;
          flex-wrap: wrap; align-items: baseline; }
.kv-row .muted { font-size: 12px; }

/* notes display */
pre.notes { white-space: pre-wrap; background: #f9fafb; padding: 12px; border-radius: 4px; }

/* login page */
.auth-page {
  background: #1f2937; min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
}
.auth-form {
  background: white; padding: 32px; border-radius: 12px;
  width: 320px; box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.auth-form h1 { color: #2563eb; }
.auth-form input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 4px; }
.auth-form button { width: 100%; padding: 12px; background: #2563eb; color: white; border: none; border-radius: 4px; margin-top: 12px; }

/* TikTok-трекинг */
.badge { display: inline-block; padding: 1px 8px; font-size: 12px; border-radius: 10px;
         background: #ede9fe; color: #6d28d9; vertical-align: middle; }
.badge.danger { background: #fee2e2; color: #b91c1c; }
tr.is-action { background: #fffbeb; }
.btn-small { padding: 3px 10px; font-size: 12px; background: white; color: #1f2937;
             border: 1px solid #d1d5db; border-radius: 4px; cursor: pointer; }
.btn-small:hover { border-color: #2563eb; color: #2563eb; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 4px; }
.under { color: #b91c1c; font-weight: 600; }
td.under, .num.under { background: #fef2f2; }
.lc-hit:hover { fill-opacity: .07 !important; }

/* План публикаций (контент-календарь) */
.plan-nav { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.plan-nav .btn-small.cur { background: #2563eb; color: #fff; border-color: #2563eb; }
.plan-nav strong { margin-left: 8px; color: #374151; }

.plan-grid { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; }
.plan-grid th, .plan-grid td { border: 1px solid #e5e7eb; padding: 6px; vertical-align: top; }
.plan-grid thead th { background: #f9fafb; color: #6b7280; text-align: center; font-size: 12px; line-height: 1.3; }
.plan-grid thead th .dnum { font-size: 16px; font-weight: 700; color: #374151; }
.plan-grid td.blg, .plan-grid th.blg { text-align: left; width: 150px; position: sticky; left: 0; background: #fff; z-index: 1; }
.plan-grid th.blg { background: #f9fafb; }
.plan-grid td.blg a { font-weight: 600; }
.plan-grid .blg-sub { font-size: 11px; color: #6b7280; margin-top: 2px; }
.plan-grid .cell { height: 56px; cursor: pointer; transition: background .1s; }
.plan-grid .cell:hover { background: #eff6ff; }
.plan-grid .cell.planned:hover, .plan-grid .cell.done:hover,
.plan-grid .cell.missed:hover, .plan-grid .cell.extra:hover { filter: brightness(.97); }
.plan-grid .today { box-shadow: inset 0 0 0 2px #2563eb; }
.plan-grid .wknd { background: #fafafa; }
.plan-grid .cell.planned { background: #ede9fe; }
.plan-grid .cell.done   { background: #dcfce7; }
.plan-grid .cell.missed { background: #fee2e2; }
.plan-grid .cell.extra  { background: #dbeafe; }
.plan-grid .chip { display: inline-flex; align-items: center; gap: 2px; background: #fff;
                   border: 1px solid #c4b5fd; border-radius: 5px; padding: 1px 5px; margin: 1px;
                   font-size: 11px; line-height: 18px; }
.plan-grid .chip a { color: #6d28d9; text-decoration: none; }
.plan-grid .chip.match { border-color: #10b981; background: #ecfdf5; }
.plan-grid .chip .mtick { color: #047857; font-weight: 700; }
.plan-grid .chip.fact { border-color: #6ee7b7; background: #ecfdf5; color: #047857; }
.plan-grid .chip.fact a { color: #047857; }
.plan-grid .chipx { border: none; background: none; color: #b91c1c; cursor: pointer; padding: 0; font-size: 13px; line-height: 1; }
.plan-grid .cell-edit { margin-top: 3px; }
.plan-grid .cell-inp { width: 96px; font-size: 11px; padding: 2px 5px; border: 1px solid #6d28d9; border-radius: 4px; }
.plan-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: 12px; color: #4b5563; margin: 8px 0; }
.plan-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 4px; }
.plan-legend .sw.planned { background: #ede9fe; } .plan-legend .sw.done { background: #dcfce7; }
.plan-legend .sw.missed { background: #fee2e2; } .plan-legend .sw.extra { background: #dbeafe; }
