:root {
  --primary: #0f62a5;
  --primary-dark: #0a4a7d;
  --accent: #17a2b8;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e2e8f0;
  --success: #12804b;
  --warning: #b7791f;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-top: 56px;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.navbar .brand { font-size: 18px; font-weight: 700; color: #fff; }
.navbar .brand:hover { text-decoration: none; }
.navbar nav { display: flex; gap: 4px; flex: 1; align-items: center; flex-wrap: wrap; }
.navbar nav a {
  color: #dbeafe;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
}
.navbar nav a:hover { background: rgba(255,255,255,0.12); text-decoration: none; color: #fff; }
.navbar .userbox { font-size: 13px; display: flex; align-items: center; gap: 10px; }
.navbar .userbox a { color: #fff; }
.badge-role {
  background: rgba(255,255,255,0.18);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
}
.card h1, .card h2 { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.stat .num { font-size: 30px; font-weight: 700; color: var(--primary); }
.stat .label { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; background: #fff; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; }
tr:hover td { background: #fafbfc; }

table thead th {
  position: sticky;
  top: 56px;
  z-index: 10;
  background: #f8fafc;
}
table thead th:first-child {
  left: 0;
  z-index: 30;
  background: #f8fafc;
}
table tbody th:first-child,
table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
}
table tbody td:first-child { background: #fff; }
table tbody th:first-child { background: #f8fafc; }
table tbody tr:hover td:first-child { background: #fafbfc; }

.table-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 8px; }
.table-scroll table thead th { top: 0; }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.success { background: var(--success); }
.btn.warning { background: var(--warning); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

form .field { margin-bottom: 14px; }
label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.status.new { background: #e0f2fe; color: #075985; }
.status.in_work { background: #fef9c3; color: #854d0e; }
.status.done { background: #dcfce7; color: #14532d; }
.status.sent_to_client { background: #ede9fe; color: #4c1d95; }
.status.rejected { background: #fee2e2; color: #991b1b; }
.status.cancelled { background: #e5e7eb; color: #374151; }

.status.deadline-warning { background: #ffedd5; color: #9a3412; }
.status.deadline-overdue { background: #fee2e2; color: #991b1b; }
.status.deadline-done-overdue {
  background: linear-gradient(90deg, #dcfce7 0%, #dcfce7 50%, #fee2e2 50%, #fee2e2 100%);
  color: #374151;
}

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert.success { background: #dcfce7; color: #14532d; border: 1px solid #bbf7d0; }

.progress-wrap { background: var(--border); border-radius: 6px; height: 14px; overflow: hidden; margin-top: 8px; }
.progress-bar { background: var(--accent); height: 100%; width: 0; transition: width 0.2s; }

.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.filelist { list-style: none; padding: 0; margin: 0; }
.filelist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 8px; background: #eef2ff; color: #3730a3; }

.auth-wrap { max-width: 420px; margin: 60px auto; }
.center { text-align: center; }
