:root {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-border: #e5e9f0;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-primary: #1f4e79;
  --color-primary-dark: #163a5a;
  --color-active: #ef4444;
  --color-wip: #3b82f6;
  --color-waiting: #f59e0b;
  --color-done: #22c55e;
  --sidebar-width: 240px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
}

.content {
  margin-left: var(--sidebar-width);
  padding: 32px 40px;
  flex: 1;
  max-width: 1240px;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 24px;
}
.sidebar-logo { font-size: 28px; }
.sidebar-title { font-weight: 700; font-size: 16px; }
.sidebar-subtitle { font-size: 13px; color: var(--color-text-muted); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.sidebar-nav a:hover { background: var(--color-bg); }
.sidebar-nav a.active { background: #eaf0fa; color: var(--color-primary); }

.sidebar-logout { margin-top: 16px; }
.sidebar-logout button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-muted);
}
.sidebar-logout button:hover { background: var(--color-bg); }

/* ─── Page elements ──────────────────────────────────────────────────────── */
.page-title { font-size: 24px; font-weight: 700; margin: 0 0 24px; }
.section-title { font-size: 16px; font-weight: 600; margin: 0 0 16px; }

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}
.flash-success { background: #ecfdf5; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ─── Stat cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}
.stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }
.stat-active  .stat-value { color: var(--color-active); }
.stat-wip     .stat-value { color: var(--color-wip); }
.stat-waiting .stat-value { color: var(--color-waiting); }
.stat-done    .stat-value { color: var(--color-done); }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
  align-items: start;
}

/* ─── Actions ────────────────────────────────────────────────────────────── */
.actions-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.actions-bar form { margin: 0; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover   { background: var(--color-primary-dark); }
.btn-secondary { background: #f1f3f5; color: var(--color-text); }
.btn-secondary:hover { background: #e5e9f0; }
.btn-danger    { background: #fef2f2; color: #dc2626; }
.btn-danger:hover    { background: #fee2e2; }
.btn-success   { background: #ecfdf5; color: #16a34a; }
.btn-success:hover   { background: #d1fae5; }
.btn-warning   { background: #fffbeb; color: #d97706; }
.btn-warning:hover   { background: #fef3c7; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active  { background: rgba(239,68,68,0.1);  color: var(--color-active); }
.badge-wip     { background: rgba(59,130,246,0.1); color: var(--color-wip); }
.badge-waiting { background: rgba(245,158,11,0.1); color: var(--color-waiting); }
.badge-done    { background: rgba(34,197,94,0.1);  color: var(--color-done); }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  padding: 12px 14px;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--color-border);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table tbody tr:nth-child(even) { background: #fafbfc; }
.table tbody tr:hover { background: #eef2f7; cursor: pointer; }
.table .truncate {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Filter tabs ────────────────────────────────────────────────────────── */
.filter-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-tabs a {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.filter-tabs a.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-card { max-width: 600px; }
form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 6px;
  color: var(--color-text-muted);
}
form label:first-of-type { margin-top: 0; }
input[type=text], input[type=password], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  resize: vertical;
}
input:focus, textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
  background: #fff;
}
.form-actions { margin-top: 20px; display: flex; gap: 12px; }
.inline-form { margin-top: 16px; }
.hidden { display: none; }

/* ─── Task detail ────────────────────────────────────────────────────────── */
.task-status { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.task-date { font-size: 13px; color: var(--color-text-muted); }

.info-list { margin: 0; }
.info-list dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-top: 14px;
}
.info-list dt:first-child { margin-top: 0; }
.info-list dd { margin: 4px 0 0; font-size: 14px; white-space: pre-wrap; }

/* ─── Timeline ───────────────────────────────────────────────────────────── */
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.timeline li { border-left: 2px solid var(--color-border); padding-left: 14px; font-size: 13px; }
.timeline-date { color: var(--color-text-muted); margin-right: 8px; }
.timeline-status { font-weight: 600; }
.timeline-user { color: var(--color-text-muted); }
.timeline-comment { margin-top: 4px; font-style: italic; color: var(--color-text-muted); }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ─── Supplies ───────────────────────────────────────────────────────────── */
.op-summary {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--color-text-muted);
}
.supplies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.supply-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.supply-photo {
  aspect-ratio: 4 / 3;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.supply-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.supply-photo-placeholder { font-size: 36px; color: var(--color-border); }
.supply-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.supply-company { font-weight: 700; font-size: 15px; }
.supply-item { font-size: 13px; color: var(--color-text); }
.supply-meta { display: flex; justify-content: space-between; font-size: 13px; }
.supply-cost { font-weight: 700; color: var(--color-primary); }
.supply-store { color: var(--color-text-muted); }
.supply-contact { font-size: 12px; color: var(--color-text-muted); }
.supply-footer {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 6px;
  border-top: 1px solid var(--color-border);
  padding-top: 8px;
}

/* ─── Login page ─────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}
.login-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: 360px;
  text-align: center;
}
.login-logo { font-size: 40px; margin-bottom: 8px; }
.login-card h1 { font-size: 18px; margin: 0 0 20px; }
.login-card form { text-align: left; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .sidebar-brand { padding: 4px 12px; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-logout { margin: 0; }
  .layout { flex-direction: column; }
  .content { margin-left: 0; padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
