:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b91c1c;
    --success: #15803d;
    --sidebar: #0f172a;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", "Noto Sans Georgian", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: var(--sidebar);
    color: #cbd5e1;
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .5px;
}
.brand-mark.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }
.brand-text { font-weight: 600; color: #f8fafc; font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    padding: 9px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 13.5px;
    display: block;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(15,118,110,.35); color: #fff; font-weight: 600; }

/* Collapsible navigation groups */
.nav-group { margin: 2px 0; }
.nav-group > summary {
    list-style: none;
    cursor: pointer;
    padding: 9px 12px;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after {
    content: "▾";
    font-size: 10px;
    transition: transform .15s ease;
}
.nav-group[open] > summary::after { transform: rotate(180deg); }
.nav-group > summary:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.nav-group-items { display: flex; flex-direction: column; gap: 2px; padding-left: 8px; }
.nav-group-items .nav-item { font-size: 13px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta small { color: var(--muted); font-size: 11.5px; }

/* Profile dropdown */
.user-menu { position: relative; }
.user-menu > summary {
    list-style: none;
    cursor: pointer;
    padding: 5px 9px;
    border-radius: 9px;
    border: 1px solid transparent;
    user-select: none;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: #f8fafc; border-color: var(--border); }
.user-menu[open] > summary { background: #f8fafc; border-color: var(--border); }
.caret { color: var(--muted); font-size: 10px; margin-left: 2px; }

.user-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 190px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 26px rgba(15,23,42,.12);
    padding: 6px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.user-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 11px;
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--text);
    background: transparent;
    border: none;
    font-family: inherit;
    cursor: pointer;
}
.user-menu-item:hover { background: #f1f5f9; text-decoration: none; }
.user-menu-form { margin: 0; }
.user-menu-logout { color: var(--danger); }
.user-menu-logout:hover { background: #fee2e2; }

.content { padding: 22px 24px 40px; display: flex; flex-direction: column; gap: 18px; }

/* ----------------------------------------------------------------- cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.subhead { font-size: 13px; font-weight: 600; margin: 16px 0 6px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--primary-dark); }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.table td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
.table th:last-child, .table td:last-child { width: 1%; white-space: nowrap; }

.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }
.notes { background: #f8fafc; border-left: 3px solid var(--primary); padding: 10px 12px; border-radius: 6px; }
.mt { margin-top: 16px; }

/* --------------------------------------------------------------- buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: #e2e8f0;
    color: var(--text);
    font-family: inherit;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.inline { display: inline; }

/* ----------------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: #334155; }
.field input, .field select, .field textarea {
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,118,110,.12);
}
.field textarea { resize: vertical; }

/* Amount + currency pair */
.money-row { display: flex; gap: 8px; }
.money-row input { flex: 1; min-width: 0; }
.money-row select { flex: 0 0 84px; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}
.fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.fieldset legend { font-size: 12.5px; font-weight: 600; color: #334155; padding: 0 6px; }

.form-actions { display: flex; gap: 10px; padding-top: 4px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select {
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    min-width: 180px;
}

/* ------------------------------------------------------------------- tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.tab {
    padding: 8px 16px;
    border-radius: 8px 8px 0 0;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -1px;
}
.tab:hover { color: var(--text); background: #f8fafc; text-decoration: none; }
.tab.active {
    color: var(--primary-dark);
    background: var(--surface);
    border-color: var(--border);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--primary);
}

.view-toggle { display: flex; gap: 6px; margin-left: auto; }

/* ---------------------------------------------------------------- board */
.board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    align-items: start;
}
.board-col {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
}
.board-col-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.board-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: #e2e8f0;
    border-radius: 999px;
    padding: 1px 8px;
}
.board-cards { display: flex; flex-direction: column; gap: 8px; }
.board-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.board-card:hover { border-color: var(--primary); text-decoration: none; box-shadow: 0 2px 6px rgba(15, 118, 110, .15); }
.board-card-title { font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.board-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.board-card-assignees { margin-top: 6px; font-size: 12px; color: var(--muted); }
.board-empty { font-size: 12.5px; padding: 6px 2px; }

.overdue { color: var(--danger); font-weight: 600; }

/* ---------------------------------------------------------- rich text */
.rich-editor { background: #fff; }
.rich-text { line-height: 1.65; }
.rich-text p { margin: 0 0 8px; }
.rich-text ul, .rich-text ol { margin: 0 0 8px; padding-left: 22px; }
.rich-text blockquote {
    margin: 0 0 8px;
    padding: 6px 12px;
    border-left: 3px solid var(--primary);
    background: #f8fafc;
    color: var(--muted);
}
.rich-text pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 10px 12px;
    border-radius: 8px;
    overflow-x: auto;
}
.rich-text code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.rich-text pre code { background: transparent; padding: 0; }

/* ---------------------------------------------------------------- badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: var(--success); }
.badge-low { background: #e0f2fe; color: #0369a1; }
.badge-normal { background: #e2e8f0; color: #334155; }
.badge-high { background: #fef3c7; color: #b45309; }
.badge-urgent { background: #fee2e2; color: var(--danger); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: #f1f5f9; border-radius: 999px; padding: 5px 12px; font-size: 12.5px; }

/* ----------------------------------------------------------------- lists */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 7px;
    font-size: 13.5px;
}
.list li small { color: var(--muted); }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    background: #f8fafc;
    border-radius: 7px;
}
.task-title { flex: 1; }
.task-due { color: var(--muted); font-size: 12.5px; }

.detail-list { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
.detail-list dt { color: var(--muted); font-size: 12.5px; }
.detail-list dd { margin: 0; font-size: 13.5px; }

/* ------------------------------------------------------------- flash/msg */
.flash-stack { display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    border: 1px solid transparent;
}
.flash-success { background: #dcfce7; color: #14532d; border-color: #bbf7d0; }
.flash-error { background: #fee2e2; color: #7f1d1d; border-color: #fecaca; }
.flash-info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

.error-message { color: var(--danger); font-size: 15px; }

/* ----------------------------------------------------------- pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.page-info { color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------------- login */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
    padding: 20px;
}
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-head { text-align: center; margin-bottom: 22px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.login-head h2 { margin: 0; font-size: 19px; }
.login-head p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------------- errors */
.error-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.error-card {
    max-width: 460px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 32px;
}
.error-code {
    font-size: 52px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}
.error-message { color: var(--text); font-size: 15px; margin: 0; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 860px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; flex: none; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .content { padding: 16px; }
    .detail-list { grid-template-columns: 1fr; }
}
