:root {
  --accent: #3E6B65;
  --accent-deep: #2B4C48;
  --accent-soft: #E4ECEA;

  --bg: #EEF1F3;
  --card: #ffffff;
  --text: #102534;
  --muted: #5b6f7c;
  --line: #d4dee6;
  --line-strong: #b8cad4;
  --line-control: #7C93A1;

  --warm: #B97A4A;
  --danger: #a12e2e;
  --ok: #1c7a4a;

  --green: var(--accent);
  --green-d: var(--accent-deep);
  --green-l: var(--accent-soft);
  --green-m: var(--accent);
  --border: var(--line);

  --ink-950: #0B1B19;
  --ink-800: #16332F;
  --brand-gradient: linear-gradient(170deg, var(--ink-950) 0%, var(--ink-800) 55%, var(--accent-deep) 100%);

  --radius: 0;
  --radius-sm: 0;
  --radius-xs: 0;
  --radius-2xs: 0;
  --radius-pill: 0;

  --card-pad: 0.9rem 1rem;
  --card-pad-lg: 1.1rem 1.2rem;
  --row-pad: 0.55rem 1rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --font: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --shadow-sm: 0 1px 3px rgba(16, 37, 52, 0.08);
  --shadow-md: 0 4px 16px rgba(16, 37, 52, 0.10);

  --icon-chevron-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");
  --icon-paperclip: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48'/%3E%3C/svg%3E");

  --sidebar-w: clamp(200px, 15vw, 260px);
  --shell-w: min(1400px, 92vw);
  --panel-right-w: clamp(340px, 32vw, 480px);

  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.625rem;
  --text-2xl: 2.25rem;
  --text-display: clamp(2rem, 3.2vw + 0.72rem, 3.6rem);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, svg, video { max-width: 100%; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn, .btn-primary, .btn-secondary, .btn-tertiary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: var(--text-sm); font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.04s;
}

.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(62, 107, 101, 0.25); }
.btn-primary:hover { background: var(--accent-deep); box-shadow: 0 4px 12px rgba(62, 107, 101, 0.35); }
.btn-secondary, .btn-ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-secondary:hover, .btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-tertiary { background: transparent; color: var(--muted); }
.btn-tertiary:hover { color: var(--accent); background: var(--accent-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn:active, .btn-primary:active, .btn-secondary:active, .btn-tertiary:active, .btn-ghost:active, .btn-danger:active { transform: translateY(1px); }
.btn:disabled, .btn-primary:disabled, .btn-secondary:disabled, .btn-tertiary:disabled, .btn-ghost:disabled, .btn-danger:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 0.32rem 0.6rem; font-size: var(--text-xs); }
.btn-block { width: 100%; }

.input, .select, .textarea {
  width: 100%;
  font-family: inherit; font-size: var(--text-base); color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--line-control);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  outline: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(62, 107, 101, 0.12); }
.input::placeholder, .textarea::placeholder { color: #b0bfc8; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.select { cursor: pointer; }
.textarea { min-height: 78px; resize: vertical; }

.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field > label, .field-label { font-size: var(--text-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field-hint { font-size: var(--text-xs); color: var(--muted); }
.field-error { font-size: var(--text-xs); color: var(--danger); font-weight: 600; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.85rem 1rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.panel-title { font-size: var(--text-base); font-weight: 700; color: var(--text); }
.panel-body { padding: var(--card-pad); }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-head { background: var(--bg); border-bottom: 1px solid var(--line); font-size: var(--text-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.table-row { padding: var(--row-pad); border-bottom: 1px solid var(--bg); }

.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.16rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 700;
  background: var(--accent-soft); color: var(--accent-deep);
  border: 1px solid transparent;
}
.chip-dot { width: 9px; height: 9px; border-radius: var(--radius-2xs); flex: none; border: 1px solid rgba(0, 0, 0, 0.15); }
.chip-muted { background: var(--bg); color: var(--muted); border-color: var(--line); }
.chip-warn { background: #fff5e2; color: #8a5a14; }
.chip-danger { background: #fdeceb; color: var(--danger); }
.chip-ok { background: #e4f4ec; color: var(--ok); }

.status-ind {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.16rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.02em;
  white-space: nowrap; flex: none;
  background: color-mix(in srgb, var(--ind-color, var(--muted)) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--ind-color, var(--line)) 30%, #fff);
  color: color-mix(in srgb, var(--ind-color, var(--text)) 72%, #000);
}
.status-ind::before {
  content: ''; width: 6px; height: 6px; border-radius: 0;
  background: var(--ind-color, var(--muted)); flex: none;
}
.status-ind[data-tone='solid'] {
  background: var(--ind-color, var(--muted));
  border-color: var(--ind-color, var(--muted));
  color: #fff;
}
.status-ind[data-tone='solid']::before { background: rgba(255, 255, 255, 0.85); }
.status-ind[data-dot='none']::before { display: none; }

.status-ind.is-ok { --ind-color: var(--ok); }
.status-ind.is-accent { --ind-color: var(--accent); }
.status-ind.is-warn { --ind-color: var(--warm); }
.status-ind.is-danger { --ind-color: var(--danger); }
.status-ind.is-info { --ind-color: #45688f; }
.status-ind.is-muted { --ind-color: var(--muted); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 32, 40, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: min(560px, 96vw);
  max-height: min(86vh, 900px);
  overflow-y: auto;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .panel-header, .panel-body { padding: 0.85rem 1rem; }
  .modal { width: 100%; max-height: 94vh; }
  .input, .select, .textarea { font-size: 16px; min-height: 40px; }
}

@media (min-width: 1600px) {
  :root { --shell-w: min(1600px, 88vw); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
