:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e4e8f0;
    --text: #1f2733;
    --muted: #7a8699;
    --primary: #4f6ef7;
    --primary-dark: #3a57d8;
    --success-bg: #e6f7ed; --success-fg: #1b7f4b;
    --error-bg: #fdeaea; --error-fg: #c0392b;
    --warn-bg: #fff6e5; --warn-fg: #b8791b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 30, 60, .08), 0 6px 20px rgba(20, 30, 60, .04);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; }
.muted { color: var(--muted); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px;
    background: #0f1729;
    color: #c7d0e0;
    padding: 18px 14px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sidebar .brand { font-size: 18px; font-weight: 700; margin-bottom: 18px; padding: 0 8px; }
.sidebar .brand a { color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    color: #c7d0e0; padding: 9px 12px; border-radius: 8px; font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .ic { width: 18px; text-align: center; }
.nav-section { margin: 16px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #66738c; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 14px 24px;
}
.topbar-title { font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 14px; }
.user-name { font-size: 14px; color: var(--muted); }
.content { padding: 24px; max-width: 1100px; width: 100%; }

/* ---------- Auth ---------- */
.guest-body { background: linear-gradient(135deg, #4f6ef7, #6a3df7); }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 400px; }
.auth-brand { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 18px; }
.auth-title { font-size: 22px; text-align: center; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: #3a4456; }
input, select, textarea {
    font: inherit; padding: 9px 11px; border: 1px solid var(--border);
    border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.15); }
textarea { min-height: 90px; resize: vertical; }
.field-error { color: var(--error-fg); font-size: 12px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 160px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
    font: inherit; font-weight: 600; cursor: pointer; background: #eef1f7; color: var(--text);
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--error-fg); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.inline { display: inline; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: var(--success-bg); color: var(--success-fg); }
.alert-error { background: var(--error-bg); color: var(--error-fg); }
.alert-warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ---------- Cards ---------- */
.page-head { margin-bottom: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-link:hover { text-decoration: none; transform: translateY(-2px); transition: transform .12s; }
.card-icon { font-size: 26px; }
.card-title { font-weight: 700; margin-top: 8px; }
.card-text { color: var(--muted); font-size: 14px; }

.placeholder-note { margin-top: 24px; padding: 14px 16px; background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; font-size: 14px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-admin { background: var(--primary); color: #fff; }

/* ---------- Errors ---------- */
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 64px; color: var(--primary); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: #f8fafd; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfe; }
.text-right { text-align: right; }

/* ---------- Layout helpers ---------- */
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-title { margin: 26px 0 14px; font-size: 18px; }
.back-link { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.small { font-size: 13px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.form-actions { display: flex; gap: 10px; align-items: center; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 30px; text-align: center; color: var(--muted); }
.card-meta { margin-top: 10px; font-size: 13px; color: var(--muted); }
.inline-form { display: flex; gap: 6px; align-items: center; }
.input-sm { padding: 5px 9px; font-size: 13px; max-width: 200px; }
.badge-role { background: #eef1f7; color: #43506b; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.filter-field select, .filter-field input { padding: 7px 9px; font-size: 13px; }
.filter-check { justify-content: flex-end; }
.filter-check label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.filter-check input { width: auto; }
.filter-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

/* ---------- Task bits ---------- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; color: #fff; font-weight: 600; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip-row { display: inline-flex; align-items: center; gap: 4px; }
.chip-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0 2px; }
.chip-del:hover { color: var(--error-fg); }
.color-input { width: 42px; height: 34px; padding: 2px; cursor: pointer; }
.nowrap { white-space: nowrap; }
.overdue { color: var(--error-fg); font-weight: 600; }
.prio { font-size: 12px; font-weight: 600; }
.prio-low { color: #6b7a90; }
.prio-medium { color: var(--warn-fg); }
.prio-high { color: var(--error-fg); }
.status-todo { border-left: 3px solid #aab4c6; }
.status-in_progress { border-left: 3px solid var(--primary); }
.status-done { border-left: 3px solid var(--success-fg); }

/* ---------- Dashboard stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-num { font-size: 30px; font-weight: 800; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- Banner (dashboard) ---------- */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 16px;
    border-radius: var(--radius); padding: 22px 26px; margin-bottom: 24px; color: #fff;
    text-decoration: none; box-shadow: var(--shadow); overflow: hidden; min-height: 90px; }
.banner:hover { text-decoration: none; filter: brightness(1.03); }
.banner-title { font-size: 20px; font-weight: 700; }
.banner-cta { font-weight: 600; opacity: .9; white-space: nowrap; }
.banner-img { max-height: 120px; width: 100%; object-fit: cover; border-radius: 6px; }

/* banner admin list */
.banner-cell { display: flex; align-items: center; gap: 10px; }
.banner-swatch { width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.08); }
.badge-on { background: var(--success-bg); color: var(--success-fg); cursor: pointer; border: none; }
.badge-off { background: #eef1f7; color: var(--muted); cursor: pointer; border: none; }

/* ---------- Tariffs ---------- */
.tariff-card { display: flex; flex-direction: column; }
.tariff-days { margin-top: 12px; font-size: 13px; color: var(--muted); }
.tariff-price { margin-top: 4px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price-old { text-decoration: line-through; color: var(--muted); font-size: 14px; }
.price-new { font-size: 24px; font-weight: 800; color: var(--text); }
.badge-discount { background: var(--success-bg); color: var(--success-fg); }

.checkout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.checkout-summary .summary { width: 100%; border-collapse: collapse; margin-top: 12px; }
.summary td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.summary .discount-row td { color: var(--success-fg); }
.summary .total-row td { border-top: 2px solid var(--border); border-bottom: none; font-size: 18px; padding-top: 10px; }
.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.ok-note { margin-top: 8px; color: var(--success-fg); font-size: 13px; font-weight: 600; }

.sub-status { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.sub-active { background: var(--success-bg); color: var(--success-fg); }
.sub-inactive { background: var(--error-bg); color: var(--error-fg); }

@media (max-width: 720px) { .checkout { grid-template-columns: 1fr; } }

/* ---------- Kanban board ---------- */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.kcol { background: #eef1f7; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kcol-head { font-weight: 700; font-size: 13px; padding: 6px 8px 10px; display: flex; align-items: center; gap: 8px; border-bottom: 2px solid transparent; }
.kcol-head.status-todo { border-color: #aab4c6; }
.kcol-head.status-in_progress { border-color: var(--primary); }
.kcol-head.status-done { border-color: var(--success-fg); }
.kcount { background: #fff; color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.kcol-body { min-height: 60px; display: flex; flex-direction: column; gap: 10px; padding: 8px 2px; border-radius: 8px; transition: background .15s; }
.kcol-body.drop-target { background: rgba(79,110,247,.10); outline: 2px dashed var(--primary); outline-offset: -2px; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; }
.kcard.dragging { opacity: .5; }
.kcard-title { display: block; font-weight: 600; color: var(--text); }
.kcard-title:hover { text-decoration: none; color: var(--primary); }
.kcard-meta { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.chip-sm { font-size: 11px; padding: 1px 7px; }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.kcard-icons { display: flex; gap: 8px; font-size: 12px; }
.kcard-assignee { margin-top: 6px; font-size: 12px; color: #43506b; }

/* ---------- Task detail ---------- */
.task-detail { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }
.task-main { min-height: 120px; }
.meta-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.meta-row:last-child { border-bottom: none; }
.meta-k { color: var(--muted); font-size: 13px; }
.status-badge { color: #fff; }
.status-badge.status-todo { background: #97a3b6; }
.status-badge.status-in_progress { background: var(--primary); }
.status-badge.status-done { background: var(--success-fg); }

/* ---------- Comments ---------- */
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.comment { border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.comment:last-child { border-bottom: none; }
.comment-head { display: flex; align-items: center; gap: 10px; }
.comment-del { margin-left: auto; }
.comment-body { margin-top: 4px; }

@media (max-width: 760px) {
    .board { grid-template-columns: 1fr; }
    .task-detail { grid-template-columns: 1fr; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .sidebar { width: 64px; }
    .sidebar .brand, .sidebar nav a span:not(.ic), .nav-section { display: none; }
    .content { padding: 16px; }
}
