:root {
  --blue:       #1F4E79;
  --blue-mid:   #2E75B6;
  --blue-light: #BDD7EE;
  --sidebar-w:  260px;
  --header-h:   60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: var(--color-background-tertiary); color: var(--color-text-primary); }

/* ── Auth ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #0d2b4e 0%, #1F4E79 55%, #2E75B6 100%); padding: 16px; }
.auth-card  { background: rgba(255,255,255,.1); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid rgba(255,255,255,.2); border-radius: 20px; padding: 40px 36px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.5); text-align: center; }
.auth-card .logo { text-align: center; margin-bottom: 28px; }
.auth-card .logo h1 { color: #fff; font-size: 1.1rem; font-weight: 600; }
.auth-card .logo p  { color: rgba(255,255,255,.7); font-size: .85rem; margin-top: 4px; }
.auth-card label { color: rgba(255,255,255,.85) !important; text-align: left; display: block; }
.auth-card .form-control { background: rgba(255,255,255,.95); border: none; border-radius: 10px; font-size: .95rem; }
.auth-card .form-control:focus { background: #fff; box-shadow: 0 0 0 3px rgba(189,215,238,.5); }
.auth-card .btn-primary { background: linear-gradient(135deg, #BDD7EE, #2E75B6); border: none; border-radius: 10px; font-size: 1rem; font-weight: 600; letter-spacing: .03em; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.auth-card .btn-primary:hover { background: linear-gradient(135deg, #dce9f5, #1F4E79); }

/* ── Layout ── */
#app     { display: none; height: 100vh; width: 100%; overflow: hidden; }
.sidebar { width: var(--sidebar-w); height: 100vh; background: var(--blue); display: flex; flex-direction: column; position: fixed; left: 0; top: 0; z-index: 100; overflow-y: auto; transition: transform .3s; }
.main    { margin-left: var(--sidebar-w); width: calc(100% - var(--sidebar-w)); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar  { height: var(--header-h); background: var(--color-background-primary); border-bottom: 0.5px solid var(--color-border-tertiary); display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.content { flex: 1; overflow-y: auto; padding: 24px; width: 100%; min-width: 0; box-sizing: border-box; max-width: 100%; }


/* ── Sidebar ── */
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-logo h2 { color: #fff; font-size: 1.1rem; font-weight: 700; }
.sidebar-logo p  { color: rgba(255,255,255,.55); font-size: .75rem; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item    { display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: rgba(255,255,255,.75); cursor: pointer; transition: all .18s; font-size: .9rem; text-decoration: none; border-left: 3px solid transparent; }
.nav-item:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; border-left-color: var(--blue-light); font-weight: 600; }
.nav-item .icon  { width: 20px; text-align: center; font-size: 1rem; font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
.nav-section     { padding: 12px 20px 4px; color: rgba(255,255,255,.35); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-footer  { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.12); }
.user-info       { color: rgba(255,255,255,.8); font-size: .82rem; }
.user-info strong{ display: block; color: #fff; font-size: .9rem; margin-bottom: 2px; }
.badge-role      { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .7rem; background: rgba(255,255,255,.15); color: rgba(255,255,255,.9); margin-top: 4px; }

/* ── Cards ── */
.card       { background: var(--color-background-primary); border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.07); padding: 20px; margin-bottom: 20px; border: 0.5px solid var(--color-border-tertiary); width: 100%; box-sizing: border-box; min-width: 0; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--blue); margin-bottom: 16px; border-bottom: 2px solid var(--blue-light); padding-bottom: 10px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card  { background: var(--color-background-primary); border-radius: 10px; padding: 18px 20px; box-shadow: 0 1px 4px rgba(0,0,0,.07); border-left: 4px solid var(--blue-mid); border-top: 0.5px solid var(--color-border-tertiary); }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--blue); }
.stat-card .stat-label { font-size: .8rem; color: var(--color-text-secondary); margin-top: 2px; }
.stat-card.warning  { border-left-color: #f59e0b; }
.stat-card.warning .stat-value { color: #92400e; }
.stat-card.success  { border-left-color: #10b981; }
.stat-card.success .stat-value { color: #065f46; }
.stat-card.danger   { border-left-color: #ef4444; }
.stat-card.danger .stat-value  { color: #991b1b; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table       { width: 100%; border-collapse: collapse; font-size: .88rem; }
th          { background: var(--blue); color: #fff; padding: 10px 12px; text-align: left; font-weight: 600; white-space: nowrap; }
td          { padding: 9px 12px; border-bottom: 0.5px solid var(--color-border-tertiary); vertical-align: middle; }
tr:hover td { background: var(--color-background-secondary); }
tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: .75rem; font-weight: 600; }
.badge-active    { background: #d1fae5; color: #065f46; }
.badge-archive   { background: var(--color-background-secondary); color: var(--color-text-secondary); }
.badge-potential { background: #fef3c7; color: #92400e; }
.badge-new       { background: #dbeafe; color: #1e40af; }
.badge-waiting   { background: #fef3c7; color: #92400e; }
.badge-closed    { background: var(--color-background-secondary); color: var(--color-text-secondary); }
.badge-suspended { background: #fce7f3; color: #9d174d; }
.badge-open      { background: #dbeafe; color: #1e40af; }
.badge-done      { background: #d1fae5; color: #065f46; }
.badge-overdue   { background: #fee2e2; color: #991b1b; }
.badge-admin     { background: #fce7f3; color: #9d174d; }
.badge-lawyer    { background: #dbeafe; color: #1e40af; }
.badge-assistant { background: #d1fae5; color: #065f46; }

/* ── Forms ── */
.form-group    { margin-bottom: 16px; }
.form-group label { display: block; font-size: .82rem; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 5px; }
.form-control  { width: 100%; padding: 9px 12px; border: 1.5px solid #9ca3af; border-radius: 7px; font-size: .9rem; transition: border-color .18s, box-shadow .18s; background: #fff; color: #111827; }
.form-control:focus { outline: none; border-color: var(--blue-mid); box-shadow: 0 0 0 3px rgba(46,117,182,.15); background: #fff; }
.form-control:hover:not(:focus) { border-color: #6b7280; }
.form-row      { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Buttons ── */
.btn          { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 7px; border: none; cursor: pointer; font-size: .88rem; font-weight: 600; transition: all .18s; text-decoration: none; }
.btn-primary  { background: var(--blue-mid); color: #fff; }
.btn-primary:hover  { background: var(--blue); }
.btn-secondary{ background: var(--color-background-secondary); color: var(--color-text-primary); border: 0.5px solid var(--color-border-secondary); }
.btn-secondary:hover{ background: var(--color-background-tertiary); }
.btn-success  { background: #10b981; color: #fff; }
.btn-success:hover  { background: #059669; }
.btn-danger   { background: #ef4444; color: #fff; }
.btn-danger:hover   { background: #dc2626; }
.btn-warning  { background: #f59e0b; color: #fff; }
.btn-warning:hover  { background: #d97706; }
.btn-sm       { padding: 5px 12px; font-size: .8rem; }
.btn-icon     { padding: 6px 10px; background: transparent; border: none; cursor: pointer; border-radius: 6px; transition: background .15s; color: var(--color-text-secondary); font-size: .9rem; }
.btn-icon:hover { background: var(--color-background-secondary); color: var(--blue); }

/* ── Toolbar ── */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .search-box { flex: 1; min-width: 200px; }
.search-input { width: 100%; padding: 8px 12px 8px 36px; border: 1.5px solid var(--color-border-secondary); border-radius: 7px; font-size: .88rem; background: var(--color-background-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.656a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E") no-repeat 10px center; color: var(--color-text-primary); }
.search-input:focus { outline: none; border-color: var(--blue-mid); }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.72); z-index: 1000; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-overlay.open { display: flex; }
.modal-box     { background: #ffffff; color: #1a1a1a; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 16px 64px rgba(0,0,0,.45); position: relative; animation: modalIn .2s ease; margin: auto; isolation: isolate; }
.modal-box.lg  { max-width: 820px; }
@keyframes modalIn { from { opacity:0; transform: translateY(-16px); } to { opacity:1; transform: translateY(0); } }
.modal-header  { padding: 18px 24px 16px; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; justify-content: space-between; background: #ffffff; border-radius: 12px 12px 0 0; }
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--blue); }
.modal-body    { padding: 20px 24px; max-height: 70vh; overflow-y: auto; background: #ffffff; color: #1a1a1a; }
.modal-body .form-group label { color: #374151; }
.modal-body .form-control { background: #ffffff; color: #111827; border: 1.5px solid #9ca3af; }
.modal-body .form-control:focus { border-color: var(--blue-mid); background: #ffffff; box-shadow: 0 0 0 3px rgba(46,117,182,.15); }
.modal-body .form-control:hover:not(:focus) { border-color: #6b7280; }
.modal-footer  { padding: 14px 24px; border-top: 1px solid #e5e7eb; display: flex; justify-content: flex-end; gap: 10px; background: #f9fafb; border-radius: 0 0 12px 12px; }
.modal-box .info-row { border-bottom-color: #e5e7eb; }
.modal-box .info-label { color: #6b7280; }
.modal-box .tab-btn { color: #6b7280; }
.modal-box .tab-btn.active { color: var(--blue); border-bottom-color: var(--blue-mid); }
.modal-box .tabs { border-bottom-color: #e5e7eb; }
.modal-box .empty-state { color: #9ca3af; }
.modal-box .alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.modal-box .alert-warning { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.modal-box .badge-active    { background: #d1fae5; color: #065f46; }
.modal-box .badge-archive   { background: #f3f4f6; color: #4b5563; }
.modal-box .badge-new       { background: #dbeafe; color: #1e40af; }
.modal-box .badge-waiting   { background: #fef3c7; color: #92400e; }
.modal-box .badge-closed    { background: #f3f4f6; color: #4b5563; }
.modal-box .badge-open      { background: #dbeafe; color: #1e40af; }
.modal-box .badge-done      { background: #d1fae5; color: #065f46; }
.modal-box .badge-overdue   { background: #fee2e2; color: #991b1b; }
.close-btn     { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #6b7280; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.close-btn:hover { background: #f3f4f6; color: #111827; }

/* ── Tabs ── */
.tabs      { display: flex; gap: 0; border-bottom: 2px solid var(--color-border-tertiary); margin-bottom: 20px; overflow-x: auto; }
.tab-btn   { padding: 10px 20px; background: none; border: none; cursor: pointer; font-size: .88rem; color: var(--color-text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; white-space: nowrap; flex-shrink: 0; }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.tab-pane  { display: none; }
.tab-pane.active { display: block; }

/* ── Alerts ── */
.alert       { padding: 10px 16px; border-radius: 7px; font-size: .88rem; margin-bottom: 12px; display: flex; align-items: flex-start; gap: 8px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success{ background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-warning{ background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info   { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Timeline ── */
.timeline { list-style: none; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 0.5px solid var(--color-border-tertiary); font-size: .85rem; }
.timeline li:last-child { border-bottom: none; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-mid); margin-top: 5px; flex-shrink: 0; }
.timeline-time { color: var(--color-text-secondary); font-size: .78rem; white-space: nowrap; }

/* ── Upload zone ── */
.upload-zone { border: 2px dashed var(--color-border-secondary); border-radius: 8px; padding: 24px; text-align: center; cursor: pointer; transition: border-color .2s; }
.upload-zone:hover, .upload-zone.drag { border-color: var(--blue-mid); background: var(--color-background-info); }
.upload-zone p { color: var(--color-text-secondary); font-size: .88rem; margin-top: 8px; }

/* ── Topbar ── */
.page-title  { font-size: 1.1rem; font-weight: 700; color: var(--blue); flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--color-text-secondary); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ── Loader ── */
.loader { display: flex; justify-content: center; padding: 40px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--color-border-tertiary); border-top-color: var(--blue-mid); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1e293b; color: #fff; padding: 12px 18px; border-radius: 8px; font-size: .88rem; box-shadow: 0 4px 16px rgba(0,0,0,.18); display: flex; align-items: center; gap: 10px; min-width: 260px; animation: toastIn .25s ease; }
.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }
.toast.warning { background: #92400e; }
@keyframes toastIn { from { opacity:0; transform: translateX(40px); } to { opacity:1; transform: translateX(0); } }

/* ── Info box ── */
.info-row { display: flex; gap: 12px; padding: 7px 0; border-bottom: 0.5px solid var(--color-border-tertiary); font-size: .88rem; }
.info-row:last-child { border-bottom: none; }
.info-label { width: 160px; color: var(--color-text-secondary); flex-shrink: 0; }
.info-value { flex: 1; }

/* ── Responsive ── */
.hamburger { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--blue); }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
  .sidebar-overlay.open { display: block; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .modal-overlay { padding: 16px; align-items: flex-end; }
  .modal-box { border-radius: 12px 12px 0 0; max-width: 100%; margin: 0; }
  .modal-body { max-height: 80vh; }
  .tabs { overflow-x: auto; }
  .table-wrap table { font-size: .8rem; }
  th, td { padding: 7px 8px; }
}
@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search-box { min-width: unset; }
}

/* ── Responsive Calendar ────────────────────────────────────────── */
@media (max-width: 600px) {
  .cal-day-name { font-size: .6rem !important; padding: 3px 0 !important; }
  .cal-nav-btn  { font-size: .75rem; padding: 5px 8px; }
  .cal-month-title { font-size: .9rem !important; }
  .timeline-time   { font-size: .7rem !important; }
}

/* ── Full responsive layout ──────────────────────────────── */
html, body { width: 100%; overflow-x: hidden; }
* { box-sizing: border-box; }
.content > * { width: 100%; max-width: 100%; }

@media (min-width: 769px) {
  #app { display: flex !important; }
}

@media (max-width: 768px) {
  .main    { margin-left: 0; width: 100%; }
  .content { padding: 14px; }
  .form-row { flex-direction: column !important; }
  .stat-cards { grid-template-columns: 1fr 1fr !important; }
  .table-wrap { overflow-x: auto; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .tab-btn { white-space: nowrap; }
  .modal-overlay { padding: 12px; align-items: flex-start; }
  .modal-box { margin: 0 auto; }
}

@media (max-width: 480px) {
  .card     { padding: 12px !important; }
  .stat-value { font-size: 1.4rem !important; }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .content  { padding: 10px; }
  .topbar  { height: var(--header-h); background: var(--color-background-primary); border-bottom: 0.5px solid var(--color-border-tertiary); display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
  .modal-box { max-width: 100% !important; }
}
/* ── Чат: фиксация шапки и ввода на мобильных ── */
@media (max-width: 900px) {
  .content.page-chat {
    overflow: hidden !important;
    padding: 0 !important;
    height: calc(100dvh - 60px) !important;
    display: flex !important;
    flex-direction: column !important;
  }
}

/* Цветные эмодзи на всех платформах */
.report-icon,.task-icon,.stat-icon,
span[style*="font-size:1."],span[style*="font-size: 1."],
span[style*="font-size:2rem"],span[style*="font-size:3rem"]{
  font-family:'Noto Color Emoji','Apple Color Emoji','Segoe UI Emoji',sans-serif!important;
}

img.emoji {
  height: 1em !important;
  width: 1em !important;
  margin: 0 0.05em 0 0.1em !important;
  vertical-align: -0.1em !important;
  display: inline !important;
}
.nav-item img.emoji { height: 1.1em !important; width: 1.1em !important; }
