/* ===== LOGIN ===== */
.login {
  position: fixed; inset: 0;
  background: radial-gradient(circle at 50% 30%, #1c2630, var(--bg));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px;
}
.login .logo { font-size: 40px; margin-bottom: 6px; }
.login h1 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.login .sub { color: var(--muted); font-size: 13px; margin-bottom: 28px; }

.dots { display: flex; gap: 14px; margin-bottom: 26px; height: 18px; }
.dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); transition: 0.15s;
}
.dot.on { background: var(--primary); border-color: var(--primary); transform: scale(1.05); }
.dots.err .dot { border-color: var(--danger); animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }

.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.key {
  height: 76px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--txt); font-size: 26px; font-weight: 500;
  transition: 0.12s;
}
.key:active { background: var(--primary); border-color: var(--primary); transform: scale(0.94); }
.key.fn { font-size: 14px; color: var(--muted); background: transparent; border: none; }
.key:disabled { opacity: 0.4; }
.hint { color: var(--muted); font-size: 12px; margin-top: 22px; text-align: center; line-height: 1.6; }
.hint b { color: var(--txt); }

/* ===== APP SHELL ===== */
.app { max-width: 1100px; margin: 0 auto; padding: 0 0 80px; flex: 1; display: flex; flex-direction: column; }
header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: calc(14px + var(--safe-top)) 18px 14px;
  display: flex; align-items: center; gap: 12px;
}
header .brand { font-weight: 700; font-size: 16px; }
header .brand span { color: var(--primary); }
header .who { margin-left: auto; font-size: 13px; color: var(--muted); }
header .exit {
  background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); border-radius: 10px;
  padding: 8px 12px; font-size: 13px;
}

main { padding: 18px; flex: 1; }
.crumb {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; margin-bottom: 16px; flex-wrap: wrap;
}
.crumb b { color: var(--txt); }
.crumb .back {
  background: var(--panel); border: 1px solid var(--line);
  color: var(--txt); border-radius: 9px;
  padding: 6px 11px; font-size: 13px;
}

h2.title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
p.lead { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* HOME GRID */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  text-align: left; color: var(--txt);
  transition: 0.15s; position: relative; overflow: hidden;
}
.tile:hover, .tile:active { border-color: var(--primary); transform: translateY(-2px); }
.tile .ic { font-size: 26px; margin-bottom: 12px; display: block; }
.tile .nm { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.tile .ds { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.tile .badge {
  position: absolute; top: 14px; right: 14px;
  background: var(--primary); color: var(--text-on-primary);
  font-size: 11px; font-weight: 700; border-radius: 20px;
  padding: 2px 8px;
}

/* CARDS */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.panel h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .lbl { font-size: 14px; }
.row .meta { margin-left: auto; color: var(--muted); font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line);
}
.chip.ok, .chip.success { color: var(--success); border-color: var(--success); }
.chip.wait, .chip.warning { color: var(--warning); border-color: var(--warning); }
.chip.buy, .chip.bought { color: var(--status-bought); border-color: var(--status-bought); }
.chip.err, .chip.danger { color: var(--danger); border-color: var(--danger); }
.chip.gray, .chip.request { color: var(--status-request); border-color: var(--status-request); }
.chip.accepted { color: var(--status-accepted); border-color: var(--status-accepted); }
.chip.absent { color: var(--status-absent); border-color: var(--status-absent); }
.chip.info { color: var(--info); border-color: var(--info); }

.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.b {
  border: none; border-radius: 11px;
  padding: 13px 16px; font-size: 14px; font-weight: 600; color: #fff;
  flex: 1; min-width: 120px; min-height: 44px;
  transition: filter 0.12s;
}
.b:hover:not(:disabled) { filter: brightness(1.08); }
.b:disabled { opacity: 0.5; }
.b.primary, .b.orange { background: var(--primary); color: var(--text-on-primary); }
.b.success, .b.green { background: var(--success); }
.b.danger, .b.red { background: var(--danger); }
.b.info, .b.blue { background: var(--info); color: var(--text-on-info); }
.b.warning, .b.yellow { background: var(--warning); color: #1a1207; }
.b.ghost { background: var(--panel2); border: 1px solid var(--line); color: var(--txt); }
.b.neutral { background: transparent; border: 1px solid var(--line); color: var(--txt); }

.seg {
  display: flex; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 11px; padding: 4px; gap: 4px; margin-bottom: 14px; width: fit-content;
}
.seg button {
  background: none; border: none; color: var(--muted);
  padding: 8px 16px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; min-height: 36px;
}
.seg button.act { background: var(--primary); color: var(--text-on-primary); }

.item {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 11px; padding: 14px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  text-align: left; color: var(--txt); width: 100%;
}
.item .av {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.item .av.m { background: var(--info); }
.item .av.e { background: var(--success); }
.item .av.b { background: var(--danger); }
.item .av.f { background: var(--warning); }
.item .tx { flex: 1; min-width: 0; }
.item .tx .t { font-weight: 600; font-size: 14.5px; }
.item .tx .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.item .arr { color: var(--muted); font-size: 18px; }
.item:hover, .item:active { border-color: var(--primary); }

.big-num { font-size: 34px; font-weight: 800; color: var(--primary); }
.stat { text-align: center; padding: 6px 0; }
.stat .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.statrow { display: flex; gap: 10px; }
.statrow > div {
  flex: 1; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 11px; padding: 14px;
}

.modelcard {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 11px; padding: 16px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
}
.modelcard .mi { font-size: 24px; }

.feed { position: relative; padding-left: 22px; }
.feed .ev {
  position: relative; padding: 0 0 16px 0;
  border-left: 2px solid var(--line);
  padding-left: 18px; margin-left: 4px;
}
.feed .ev::before {
  content: ""; position: absolute; left: -7px; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--bg);
}
.feed .ev:last-child { border-left-color: transparent; }
.feed .ev .d { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.feed .ev .m { font-size: 14px; }

textarea, input.txt, select.txt {
  width: 100%; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 11px;
  color: var(--txt); padding: 12px; font-size: 14px;
  resize: vertical; min-height: 44px;
}
label.fl { display: block; font-size: 13px; color: var(--muted); margin: 6px 0 4px; }

.note {
  background: rgba(58, 160, 255, 0.08);
  border: 1px solid rgba(58, 160, 255, 0.3);
  border-radius: 11px; padding: 12px;
  font-size: 14px; color: var(--txt); margin-bottom: 14px;
  line-height: 1.5;
}
.note .chip { vertical-align: middle; margin-right: 4px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 18px;
  z-index: 100; max-width: 90%;
  animation: slideUp 0.2s;
}
.toast.err { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--success); color: var(--success); }
@keyframes slideUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--line); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { text-align: center; padding: 40px; color: var(--muted); }

.comment-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.comment-panel textarea.txt { min-height: 60px; }
.comment-panel .btnrow { margin-top: 8px; }

/* MODAL */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
  opacity: 0; transition: opacity 0.15s;
}
.modal.open { opacity: 1; }
.modal-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); width: 100%; max-width: 480px;
  max-height: 90vh; display: flex; flex-direction: column;
  transform: scale(0.95); transition: transform 0.15s;
}
.modal.open .modal-card { transform: scale(1); }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-x {
  background: none; border: none; color: var(--muted);
  font-size: 28px; line-height: 1; padding: 0 8px; min-height: 36px;
}
.modal-x:hover { color: var(--txt); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot {
  padding: 12px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end;
}
.modal-foot .b { flex: 0; min-width: 100px; }

@media (max-width: 480px) {
  .pad { grid-template-columns: repeat(3, 64px); gap: 10px; }
  .key { height: 64px; font-size: 22px; }
  .grid { grid-template-columns: 1fr; }
  .statrow { flex-direction: column; }

  header {
    flex-wrap: wrap;
    row-gap: 6px;
    padding: calc(10px + var(--safe-top)) 14px 10px;
  }
  header .brand { font-size: 14px; flex: 1 0 auto; }
  header .who {
    font-size: 12px; width: 100%;
    order: 3; margin-left: 0;
    color: var(--muted);
  }
  header .who .role { color: var(--muted); }
  header .exit { font-size: 12px; padding: 6px 10px; min-height: 36px; }
}

@media (max-width: 360px) {
  header .who { display: none; }
}

/* ===== SIDEBAR (desktop) ===== */
.sidebar { display: none; }

@media (min-width: 1024px) {
  .sidebar {
    display: block;
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 260px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: calc(20px + var(--safe-top)) 14px 20px;
    overflow-y: auto;
    z-index: 20;
  }
  .sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
  .sb-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 14px 18px;
    text-decoration: none; color: var(--txt);
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
  }
  .sb-brand:hover { color: var(--primary); }
  .sb-brand-ic { font-size: 28px; }
  .sb-brand-tx { display: flex; flex-direction: column; line-height: 1.2; }
  .sb-brand-t { font-size: 16px; font-weight: 700; }
  .sb-brand-s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
  .sb-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 10px;
    color: var(--muted); text-decoration: none;
    font-size: 14px; font-weight: 500;
    transition: background 0.12s, color 0.12s;
    position: relative;
  }
  .sb-item:hover { background: var(--panel2); color: var(--txt); }
  .sb-item.active { background: var(--primary); color: var(--text-on-primary); }
  .sb-item.active:hover { background: var(--primary); }
  .sb-ic { font-size: 20px; width: 24px; text-align: center; flex-shrink: 0; }
  .sb-tx { flex: 1; min-width: 0; max-width: 200px; }
  .sb-nm {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
    word-break: break-word;
    white-space: normal;
  }
  .sb-badge {
    background: var(--primary); color: var(--text-on-primary);
    font-size: 11px; font-weight: 700; border-radius: 20px;
    padding: 2px 8px; min-width: 20px; text-align: center;
  }
  .sb-item.active .sb-badge { background: var(--text-on-primary); color: var(--primary); }

  .app {
    max-width: none;
    margin-left: 260px;
    padding: 0 32px 60px;
  }
  header {
    border-radius: 0 0 14px 14px;
    margin: 0 0 4px;
  }
  header .brand { font-size: 18px; }
  header .who { font-size: 14px; }
  header .exit { padding: 9px 14px; font-size: 13.5px; }

  main { padding: 28px 8px; max-width: 1280px; }

  h2.title { font-size: 26px; }
  p.lead { font-size: 15px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
  .tile { padding: 22px; }
  .tile .ic { font-size: 30px; margin-bottom: 14px; }
  .tile .nm { font-size: 16px; }
  .tile .ds { font-size: 13px; }

  .panel { padding: 20px; }
  .panel h3 { font-size: 16px; }

  .crumb .back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 7px 12px; }

  .statrow { gap: 14px; }
  .stat .big-num { font-size: 40px; }

  .item { padding: 16px; }
  .item .av { width: 42px; height: 42px; font-size: 15px; }
  .item .tx .t { font-size: 15.5px; }
  .item .tx .s { font-size: 13px; }

  .modelcard { padding: 20px; }
  .modelcard .mi { font-size: 28px; }

  .b { padding: 14px 18px; font-size: 14.5px; min-height: 46px; }

  .modal-card { max-width: 560px; }
}

@media (min-width: 1280px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .app { padding: 0 48px 60px; }
  main { max-width: 1400px; }
}

@media (min-width: 1600px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
  .sidebar { width: 300px; }
  .app { margin-left: 300px; padding: 0 64px 60px; }
  main { max-width: 1500px; }
}

.timesheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.timesheet-head .b { flex: 0 0 auto; min-width: 44px; min-height: 44px; font-size: 18px; padding: 8px 12px; }
.timesheet-head .b:hover { border-color: var(--primary); color: var(--primary); }
.timesheet-head .timesheet-month { padding: 0 8px; }

.timesheet-month {
  font-size: 18px;
  font-weight: 600;
  color: var(--txt);
  text-align: center;
  flex: 1;
}

.timesheet-total {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
}

.timesheet-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}
.timesheet-wrap table.timesheet { min-width: 480px; }

table.timesheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.timesheet th,
table.timesheet td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

table.timesheet th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table.timesheet th:first-child,
table.timesheet td:first-child {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 1;
}

table.timesheet td.hours {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

table.timesheet td.note {
  color: var(--muted);
  font-size: 13px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 767px) {
  .timesheet-wrap table.timesheet { font-size: 12px; }
  .timesheet-wrap table.timesheet th,
  .timesheet-wrap table.timesheet td { padding: 6px 5px; }
  .timesheet-wrap table.timesheet td.note { display: none; }
}

@media (max-width: 480px) {
  .timesheet-wrap table.timesheet { font-size: 11.5px; }
  .timesheet-wrap table.timesheet th,
  .timesheet-wrap table.timesheet td { padding: 5px 4px; }
  .timesheet-wrap table.timesheet th:nth-child(4),
  .timesheet-wrap table.timesheet td:nth-child(4) { display: none; }
}

table.ts { width:100%; border-collapse:collapse; font-size:12px; table-layout:fixed; }
table.ts th, table.ts td { border:1px solid var(--line); padding:3px 4px; text-align:right; vertical-align:middle; color: var(--txt); }
table.ts th { background:var(--panel2); position:sticky; top:0; font-weight:600; color:var(--muted); }
table.ts th.sticky, table.ts td.sticky { position:sticky; left:0; background:var(--panel); text-align:left; z-index:1; color: var(--txt); }
table.ts th.sticky { background:var(--panel2); z-index:2; }
table.ts tr.grand td { background:var(--panel2); color:var(--txt); font-weight:700; }
table.ts tr.grand td.sticky { background:var(--panel2); }
table.ts .cell { display:flex; flex-direction:column; align-items:flex-end; gap:1px; line-height:1.2; }
table.ts .cell .t { font-variant-numeric:tabular-nums; font-weight:600; }
table.ts .cell .m { color:var(--muted); font-size:10px; }
table.ts .dash { color:var(--muted); }
table.ts .pill { display:inline-block; padding:1px 5px; border-radius:999px; font-size:10.5px; }
table.ts .pill.err { background:rgba(226,85,99,.18); color:var(--danger); }
table.ts .day { cursor:pointer; }
table.ts .day:hover { background:var(--panel2); }
.ctrlbar { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin: 10px 0; }

.public-board { background:var(--bg); color:var(--txt); }
.board-h { background:var(--panel); color:var(--txt); padding:18px 24px; border-bottom: 1px solid var(--line); }
.board-h h1 { font-size:20px; margin:0; }
.board-h .meta { color:var(--muted); font-size:13px; margin-top:4px; }
table.board { width:100%; max-width:1100px; margin:20px auto; background:var(--panel); border-collapse:collapse; font-size:16px; color:var(--txt); }
table.board th, table.board td { padding:10px 12px; border-bottom:1px solid var(--line); text-align:left; color:var(--txt); }
table.board th { background:var(--panel2); font-weight:600; color:var(--muted); }
table.board td:not(:first-child) { text-align:right; font-variant-numeric:tabular-nums; }
.pill.err { background:rgba(226,85,99,.18); color:var(--danger); padding:2px 8px; border-radius:6px; }
