:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-alt: #eef3f6;
  --ink: #20262d;
  --muted: #69737e;
  --line: #dbe1e6;
  --brand: #166b68;
  --brand-strong: #0f5452;
  --open: #c75f2c;
  --progress: #1f6fb2;
  --critical: #b83246;
  --sla: #87621a;
  --shadow: 0 14px 40px rgba(31, 43, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans JP", "Noto Sans KR", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel .primary-button {
  min-height: 44px;
}

.login-error {
  margin: -6px 0 0;
  color: var(--critical);
  font-size: 0.86rem;
  font-weight: 850;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.8rem, 2.4vw, 2.7rem);
}

h2 {
  font-size: 1.35rem;
}

.topbar-actions,
.toolbar,
.form-actions,
.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 3px;
}

.lang-button {
  min-width: 76px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-weight: 750;
}

.lang-button.active {
  background: var(--brand);
  color: #fff;
}

.icon-button,
.ghost-button,
.primary-button,
.danger-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--brand);
  color: #fff;
}

.primary-button:hover,
.lang-button.active:hover {
  background: var(--brand-strong);
}

.danger-button {
  margin-right: auto;
  background: #fff4f3;
  border-color: #f0c7c1;
  color: #a33c31;
}

.workspace {
  display: block;
}

.main-panel,
.modal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.main-panel {
  padding: 18px;
  min-width: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 94px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 8px;
  padding: 15px;
  background: #fbfcfc;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
}

.accent-open {
  border-left-color: var(--open);
}

.accent-progress {
  border-left-color: var(--progress);
}

.accent-critical {
  border-left-color: var(--critical);
}

.accent-sla {
  border-left-color: var(--sla);
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.settings-panel {
  position: relative;
}

.settings-panel summary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 850;
  list-style: none;
  cursor: pointer;
}

.settings-panel summary::-webkit-details-marker {
  display: none;
}

.settings-grid {
  position: absolute;
  right: 0;
  z-index: 3;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 48px));
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-grid label {
  font-size: 0.78rem;
}

.search-field {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: none;
  color: var(--ink);
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.toolbar select {
  min-height: 42px;
  padding: 0 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-alt);
  color: #52606d;
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #f2faf9;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.ticket-title {
  display: grid;
  gap: 4px;
}

.ticket-title strong {
  font-size: 0.96rem;
}

.ticket-title span {
  color: var(--muted);
  font-size: 0.8rem;
}

.subtle {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.status-registered {
  background: #fff3e8;
  color: var(--open);
}

.status-received {
  background: #f4f0ff;
  color: #6550a8;
}

.status-responding {
  background: #edf4ff;
  color: var(--progress);
}

.status-completed {
  background: #edf7ed;
  color: #367a44;
}

.sla-warning {
  color: var(--critical);
  font-weight: 850;
}

.media-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 0.78rem;
  text-decoration: none;
}

.download-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  background: #fbfcfc;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 850;
  text-decoration: none;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 0;
}

form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.stage-fieldset {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.stage-fieldset[hidden] {
  display: none;
}

.stage-fieldset legend {
  padding: 0 6px;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 850;
}

label {
  display: grid;
  gap: 7px;
  color: #4e5964;
  font-size: 0.86rem;
  font-weight: 800;
}

label input,
label select,
label textarea {
  width: 100%;
  padding: 10px 11px;
  color: var(--ink);
  font-weight: 500;
}

input[type="file"] {
  padding: 9px;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.media-preview {
  display: grid;
  gap: 10px;
}

.media-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.media-card img,
.media-card video {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #12171c;
}

.media-card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
}

.media-card-footer span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-remove {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(18, 24, 28, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(860px, calc(100vh - 44px));
  overflow: auto;
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
}

.form-modal {
  width: min(780px, 100%);
}

.media-modal {
  width: min(980px, 100%);
}

.media-viewer {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.viewer-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.viewer-card img,
.viewer-card video {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  background: #12171c;
}

.empty-state {
  padding: 42px 14px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .toolbar {
    width: 100%;
  }

  .language-switch,
  .toolbar .primary-button,
  .toolbar select {
    width: 100%;
  }

  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 78px;
  }
}
