:root {
  --blue: #1d4ed8;
  --blue-dark: #1e3a8a;
  --blue-soft: #eff6ff;
  --blue-line: #dbeafe;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f5f7fb;
  --card: #ffffff;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --green: #15803d;
  --green-soft: #f0fdf4;
  --radius: 12px;
  --font: "Segoe UI", "Noto Sans Armenian", "Arial", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; font-size: 15px; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.late { color: var(--red); font-weight: 600; }
.soon { color: var(--amber); font-weight: 600; }

/* Կոճակներ և դաշտեր */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: .15s; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-light { background: #fff; border-color: var(--line); color: var(--text); }
.btn-light:hover { border-color: var(--blue); color: var(--blue); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-light { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: transparent; font-size: 22px; cursor: pointer; width: 38px; height: 38px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--blue-soft); color: var(--blue); }
input, select, textarea { font: inherit; color: inherit; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-line); border-color: var(--blue); }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field-label { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; cursor: pointer; }
.form-section { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--blue); margin: 4px 0 12px; }
.form-section:not(:first-child) { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.input-btn { display: flex; gap: 8px; }
.input-btn input { flex: 1; letter-spacing: .08em; }
.lookup-box { border-radius: 10px; padding: 10px 14px; margin: -4px 0 14px; font-size: 14px; background: var(--bg); border: 1px solid var(--line); }
.lookup-box p { margin: 0 0 6px; }
.lookup-box p:last-child { margin-bottom: 0; }
.lookup-info { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-dark); }
.lookup-ok { background: var(--green-soft); border-color: #bbf7d0; color: var(--green); }
.lookup-err { background: var(--red-soft); border-color: #fecaca; color: var(--red); }
.lookup-links { margin: 6px 0 0; padding-left: 18px; }
.lookup-links li { margin: 2px 0; }
.source-line { font-size: 13px; margin: -4px 0 8px; }
.form-error { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 9px; margin: 0 0 12px; }

/* Մուտքի էջ */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--blue-soft), #fff 60%); }
.login-box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 32px; box-shadow: 0 24px 60px -30px rgba(29,78,216,.4); }
.login-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); font-size: 20px; letter-spacing: .05em; font-weight: 700; margin-bottom: 22px; }
.login-brand b { color: var(--blue); }
.login-box h1 { font-size: 22px; margin-bottom: 20px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.login-note { color: var(--muted); font-size: 13px; margin: 16px 0 6px; }
.login-back { font-size: 14px; }

/* Կառուցվածք */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex: none; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; text-decoration: none; color: var(--text); font-weight: 700; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.side-brand b { color: var(--blue); }
.side-nav { padding: 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 500; }
.side-nav a:hover { background: var(--bg); }
.side-nav a.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.nav-icon { width: 22px; text-align: center; }
.side-user { padding: 16px 20px; border-top: 1px solid var(--line); }
.su-name { font-weight: 600; }
.su-role { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 20px; }
.today { margin-left: auto; color: var(--muted); font-size: 14px; }
.menu-btn { display: none; }
.main { padding: 24px 28px 48px; max-width: 1300px; width: 100%; }
.main:focus { outline: none; }

/* Բաղադրիչներ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; }
.card-head { font-weight: 700; font-size: 16px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .card { margin-bottom: 20px; }
.greeting { margin: 0 0 16px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--text); border-left: 4px solid var(--blue); }
.kpi:hover { box-shadow: 0 6px 20px -12px rgba(15,23,42,.35); }
.kpi-value { font-size: 28px; font-weight: 700; }
.kpi-label { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.kpi-danger { border-left-color: var(--red); background: var(--red-soft); }
.kpi-danger .kpi-value { color: var(--red); }
.kpi-warn { border-left-color: #f59e0b; }
.kpi-ok { border-left-color: var(--green); }
.empty { color: var(--muted); padding: 18px; text-align: center; background: var(--bg); border-radius: 9px; }
.loading { color: var(--muted); padding: 24px; }
.error-box { background: var(--red-soft); color: var(--red); padding: 16px; border-radius: 9px; }
.note { background: var(--blue-soft); border: 1px solid var(--blue-line); color: var(--blue-dark); padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.tag { display: inline-block; font-size: 12px; background: var(--blue-soft); color: var(--blue); border-radius: 6px; padding: 1px 7px; margin-left: 6px; font-weight: 600; }
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.st-new { background: #f1f5f9; color: #334155; }
.st-in_progress { background: var(--blue-soft); color: var(--blue); }
.st-review { background: var(--amber-soft); color: var(--amber); }
.st-done { background: var(--green-soft); color: var(--green); }
.st-overdue { background: var(--red); color: #fff; }
.prio { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.prio::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.pr-low::before { background: #94a3b8; }
.pr-normal::before { background: #60a5fa; }
.pr-high::before { background: #f59e0b; }
.pr-urgent { color: var(--red); }
.pr-urgent::before { background: var(--red); }

/* Ծանրաբեռնվածություն */
.workload { display: flex; flex-direction: column; gap: 4px; }
.wl-row { display: grid; grid-template-columns: 220px 1fr auto; gap: 16px; align-items: center; padding: 10px 8px; border-radius: 9px; text-decoration: none; color: var(--text); }
.wl-row:hover { background: var(--bg); }
.wl-name { font-weight: 600; display: flex; flex-direction: column; }
.wl-name small { color: var(--muted); font-weight: 400; }
.wl-bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.wl-bar span { display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, var(--blue)); border-radius: 999px; }
.wl-nums { display: flex; gap: 14px; font-size: 13px; flex-wrap: wrap; }

/* Ցուցակներ */
.compact { list-style: none; margin: 0; padding: 0; }
.compact li + li { border-top: 1px solid var(--line); }
.compact a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 4px; text-decoration: none; color: var(--text); }
.compact a:hover { background: var(--bg); }
.c-title { font-weight: 600; }
.c-sub { color: var(--muted); font-size: 13px; }
.c-side { text-align: right; flex: none; }
.c-due { font-size: 13px; display: flex; flex-direction: column; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input[type=search] { width: auto; min-width: 170px; flex: 1 1 170px; }
.filters .check { margin: 0; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.tasks-table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #fafbfd; }
.row-late { background: #fffafa; }
.row-off { opacity: .6; }
.t-title { font-weight: 600; }
.due-cell { white-space: nowrap; }
.due-cell small { display: block; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { display: flex; margin: 0 0 4px auto; }

/* Հանձնարարության էջ */
.task-head h2 { font-size: 21px; margin: 8px 0; }
.th-badges { display: flex; gap: 6px; }
.desc { white-space: pre-wrap; color: #334155; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 24px; margin: 16px 0; }
.info-grid dt { color: var(--muted); font-size: 13px; }
.info-grid dd { margin: 2px 0 0; font-weight: 600; display: flex; flex-direction: column; }
.info-grid dd small { font-weight: 400; }
.task-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); }
.status-select { width: auto; }
.comments { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comments li { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.cm-head { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.cm-body { white-space: pre-wrap; margin-top: 4px; }
.comment-form { display: flex; gap: 10px; align-items: flex-end; }
.history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.history li { padding: 7px 0; border-bottom: 1px dashed var(--line); }

.settings { max-width: 640px; }

/* Չաթ */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; line-height: 1; }
.chat { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 120px); min-height: 440px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-search { padding: 12px; border-bottom: 1px solid var(--line); }
.chat-groups { overflow-y: auto; flex: 1; padding: 6px 8px 12px; }
.chat-group-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 12px 8px 6px; }
.chat-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; text-decoration: none; color: var(--text); }
.chat-item:hover { background: var(--bg); }
.chat-item.active { background: var(--blue-soft); }
.chat-item.has-unread .ci-title { font-weight: 700; }
.ci-main { min-width: 0; flex: 1; }
.ci-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-placeholder { margin: auto; padding: 24px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat-title { font-weight: 700; }
.chat-sub { font-size: 13px; }
.chat-back { display: none; text-decoration: none; font-size: 22px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; background: #fafbfd; }
.chat-more { align-self: center; }
.msg { max-width: 75%; align-self: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 8px 12px; }
.msg-mine { align-self: flex-end; background: var(--blue-soft); border-color: var(--blue-line); border-radius: 12px 12px 4px 12px; }
.msg-head { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.msg-head b { color: var(--text); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }
.chat-composer textarea { resize: none; }
.stack .btn { margin-top: 4px; }

/* Պատուհաններ */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(15,23,42,.5); }
.modal-wide { width: min(640px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(15,23,42,.45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; }
.modal-form { padding: 18px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.secret { background: var(--bg); border: 1px dashed var(--blue); border-radius: 10px; padding: 12px 14px; margin: 10px 0; display: flex; flex-direction: column; gap: 4px; }
.secret code { font-size: 17px; background: #fff; padding: 2px 8px; border-radius: 6px; user-select: all; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); max-width: 360px; }
.toast-err { background: var(--red); }

/* Պլանշետ և հեռախոս */
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .wl-row { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-block; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 17px; }
  .today { display: none; }
  .main { padding: 16px 16px 40px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .comment-form { flex-direction: column; align-items: stretch; }
  /* Չաթ հեռախոսում՝ կամ ցանկը, կամ բաց խոսակցությունը */
  .chat { grid-template-columns: 1fr; height: calc(100vh - 100px); }
  .chat-list { border-right: 0; }
  .chat .chat-pane { display: none; }
  .chat.chat-open .chat-list { display: none; }
  .chat.chat-open .chat-pane { display: flex; }
  .chat-back { display: inline-block; }
  .msg { max-width: 90%; }
  .chat-head, .chat-messages, .chat-composer { padding-left: 12px; padding-right: 12px; }
  /* Աղյուսակները հեռախոսում ցուցադրվում են քարտերի տեսքով */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table td { border: 0; padding: 4px 14px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  .table td > * { text-align: right; }
  .table .actions { justify-content: flex-end; }
  .due-cell small { display: inline; margin-left: 6px; }
  .filters select, .filters input[type=search] { flex-basis: 100%; }
}
