:root {
  --ink: #14231f;
  --muted: #66736f;
  --line: #dfe7e3;
  --paper: #ffffff;
  --canvas: #f3f6f4;
  --accent: #087b62;
  --accent-dark: #075f4d;
  --accent-soft: #dff3ed;
  --danger: #b83434;
  --warning: #8a5a00;
  --shadow: 0 18px 45px rgba(29, 58, 49, .09);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 14px/1.55 Inter, "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(26px, 4vw, 38px); letter-spacing: -.035em; }
h2 { margin-bottom: 3px; font-size: 25px; }
h3 { margin-bottom: 18px; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 4px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .15em; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #d9efe7, transparent 35%), radial-gradient(circle at 80% 90%, #dce9f5, transparent 40%), #edf3f0; }
.login-card { width: min(430px, 100%); padding: 42px; border: 1px solid rgba(255,255,255,.8); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.brand-mark { display: grid; width: 56px; height: 56px; margin-bottom: 24px; place-items: center; border-radius: 16px; color: white; background: linear-gradient(145deg, #0b9878, #075c4b); font-weight: 850; letter-spacing: -.04em; box-shadow: 0 10px 28px rgba(8,123,98,.25); }
.brand-mark.small { width: 36px; height: 36px; margin: 0; border-radius: 11px; font-size: 12px; }
label { display: grid; gap: 7px; margin-bottom: 16px; color: #36453f; font-weight: 650; }
input, textarea, select { width: 100%; border: 1px solid #cdd9d4; border-radius: 10px; padding: 11px 12px; color: var(--ink); background: white; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,123,98,.13); }
textarea { resize: vertical; }
button { border: 1px solid var(--line); border-radius: 9px; padding: 9px 14px; color: var(--ink); background: white; font-weight: 700; }
button:hover { border-color: #b6c8c1; background: #f8faf9; }
button.primary { border-color: var(--accent); color: white; background: var(--accent); }
button.primary:hover { background: var(--accent-dark); }
button.ghost { background: transparent; }
button.danger { border-color: #e5bcbc; color: var(--danger); background: #fff7f7; }
button.full { width: 100%; margin-top: 4px; padding: 12px; }
.form-error { min-height: 22px; margin: 12px 0 0; color: var(--danger); }
.login-help { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.topbar { position: sticky; z-index: 20; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 66px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.93); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 800; }
.topbar nav { display: flex; gap: 4px; }
.nav-button { border: 0; padding: 10px 15px; color: var(--muted); background: transparent; }
.nav-button.active { color: var(--accent); background: var(--accent-soft); }
.user-menu { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.shell { width: min(1240px, calc(100% - 40px)); margin: 34px auto 80px; }
.view { display: none; }
.view.active { display: block; }
.page-heading, .detail-heading, .card-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-heading { margin-bottom: 24px; }
.detail-heading { margin: 38px 0 17px; }
.card { border: 1px solid var(--line); border-radius: 15px; padding: 20px; background: var(--paper); box-shadow: 0 5px 20px rgba(29,58,49,.035); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; padding: 13px; }
.toolbar input { max-width: 360px; }
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 13px 10px; border-bottom: 1px solid #edf1ef; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; border-radius: 20px; font-size: 12px; font-weight: 750; }
.status::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status.online, .status.succeeded { color: #087054; background: #dcf4eb; }
.status.offline, .status.failed, .status.rolled_back, .status.recovery_required { color: #9d3838; background: #fae6e6; }
.status.queued, .status.running { color: #805f00; background: #f7edcb; }
.empty { padding: 36px 12px; color: var(--muted); text-align: center; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding-top: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.metric { min-height: 92px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.metric span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.metric strong { display: block; overflow: visible; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; text-overflow: clip; white-space: normal; }
#task-summary { grid-template-columns: 1.4fr .8fr .8fr .6fr 1.6fr; }
#task-summary .metric { min-width: 0; }
#task-summary .metric strong { overflow: visible; font-size: 15px; overflow-wrap: anywhere; text-overflow: clip; white-space: normal; }
.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.key-values { display: grid; grid-template-columns: 150px 1fr; margin: 0; }
.key-values dt, .key-values dd { margin: 0; padding: 8px 0; border-bottom: 1px solid #edf1ef; }
.key-values dt { color: var(--muted); }
.key-values dd { overflow-wrap: anywhere; font-weight: 650; }
.esim-slot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.esim-slot { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfb; }
.esim-slot h4 { margin: 0 0 6px; font-size: 17px; }
.profile-list { display: grid; gap: 8px; }
.profile-item { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--paper); }
.profile-item span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 14px; margin-bottom: 14px; }
.form-grid label { margin: 0; }

dialog { width: min(620px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(7,34,27,.28); }
#task-dialog { width: min(920px, calc(100% - 28px)); }
dialog::backdrop { background: rgba(11,30,25,.5); backdrop-filter: blur(3px); }
.dialog-form { padding: 25px; }
.dialog-form.wide { width: 100%; }
.dialog-title { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.icon-button { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; font-size: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.warning { padding: 11px 13px; border-left: 3px solid #d59927; color: var(--warning); background: #fff8e9; }
.progress-track { height: 9px; margin: 3px 0 22px; overflow: hidden; border-radius: 10px; background: #e9efec; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #0aa57e, #55c9a9); transition: width .25s; }
.timeline { padding: 0 0 0 19px; }
.timeline li { padding: 0 0 18px 13px; }
.timeline li::marker { color: var(--accent); font-weight: 800; }
.timeline strong { display: block; }
.timeline small { color: var(--muted); }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: 420px; padding: 13px 17px; border-radius: 11px; color: white; background: #173f35; box-shadow: var(--shadow); }
.toast.error { background: #972f2f; }

@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .user-menu span { display: none; }
  .shell { width: min(100% - 22px, 1240px); margin-top: 22px; }
  .page-heading { align-items: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split-grid { grid-template-columns: 1fr; }
  .esim-slot-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .login-card { padding: 28px 22px; }
  .brand > span:last-child { display: none; }
  .page-heading { display: grid; }
  .metric-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input { flex: 1 0 100%; }
}
