/* edu.ktnu.uz — шартнома модули. Расмий, замонавий, мобилга мос. */
:root {
  --navy: #0B2E59;
  --navy-2: #12407A;
  --blue: #1D5FBF;
  --blue-50: #EAF2FD;
  --blue-100: #D3E4FA;
  --bg: #F3F5F8;
  --card: #FFFFFF;
  --line: #DDE3EA;
  --text: #17212F;
  --muted: #5B6878;
  --green: #18864B;
  --green-50: #E6F5EC;
  --yellow: #B7791F;
  --yellow-50: #FFF6DD;
  --red: #C62828;
  --red-50: #FDECEC;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 4px 16px rgba(16, 32, 56, .06);
  --font: "Segoe UI", "Roboto", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; font-size: 15px; }
a { color: var(--blue); }
h1, h2, h3 { color: var(--navy); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
h2 { font-size: clamp(1.15rem, 2.6vw, 1.45rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Header ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 30; }
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; }
.brand-logo { min-width: 34px; height: 34px; padding: 0 6px; border-radius: 8px; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 11px; letter-spacing: .3px; }
.brand small { display: block; font-weight: 400; opacity: .8; font-size: 12px; }
.topnav { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topnav a, .topnav button { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-size: 14px; background: transparent; border: 0; cursor: pointer; font-family: inherit; }
.topnav a:hover, .topnav button:hover { background: rgba(255,255,255,.12); }
.topnav .user { opacity: .85; font-size: 13px; padding: 0 6px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font: 600 15px/1.2 var(--font); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 1px; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--navy); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: #fff; color: var(--red); border-color: #F1C0C0; }
.btn-link { background: none; border: 0; color: var(--blue); padding: 4px 6px; min-height: auto; font-weight: 600; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13.5px; border-radius: 8px; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-lg { min-height: 52px; padding: 14px 26px; font-size: 16px; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards / layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Hero ---------- */
.hero { background: linear-gradient(135deg, var(--navy) 0%, #15457F 100%); color: #fff; padding: 56px 0 64px; }
.hero h1 { color: #fff; max-width: 760px; }
.hero p { max-width: 680px; opacity: .9; font-size: 1.05rem; }
.hero .btn-primary { background: #fff; color: var(--navy); }
.hero .btn-secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.steps-preview { counter-reset: s; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-top: -32px; }
.steps-preview li { list-style: none; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.steps-preview li::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--blue-50); color: var(--navy); font-weight: 700; margin-bottom: 8px; }

/* ---------- Wizard layout ---------- */
.wizard { display: grid; grid-template-columns: 270px 1fr; gap: 24px; padding: 24px 0 120px; align-items: start; }
.stepper { position: sticky; top: 76px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.stepper ol { list-style: none; margin: 0; padding: 0; }
.stepper li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.stepper li .num { flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; border: 2px solid var(--line); background: #fff; }
.stepper li.done { color: var(--text); }
.stepper li.done .num { background: var(--green); border-color: var(--green); color: #fff; }
.stepper li.current { background: var(--blue-50); color: var(--navy); font-weight: 600; }
.stepper li.current .num { background: var(--navy); border-color: var(--navy); color: #fff; }
.stepper li.clickable { cursor: pointer; }
.stepper li.clickable:hover { background: var(--bg); }
.stepper .progress { height: 4px; background: var(--bg); border-radius: 4px; margin: 6px 10px 10px; overflow: hidden; }
.stepper .progress span { display: block; height: 100%; background: var(--navy); transition: width .25s; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.panel-head .badge-step { flex: 0 0 auto; background: var(--blue-50); color: var(--navy); border-radius: 8px; padding: 4px 10px; font-weight: 700; font-size: 13px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); }

.actions { position: sticky; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); margin: 24px -24px -24px; padding: 14px 24px; display: flex; gap: 12px; align-items: center; border-radius: 0 0 var(--radius) var(--radius); z-index: 5; }
.actions .summary { font-size: 14px; color: var(--muted); }
.actions .summary b { color: var(--navy); font-size: 16px; }

/* ---------- Selectable cards ---------- */
.choice { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 18px; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.choice:hover { border-color: #9DB8E0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice.selected { border-color: var(--blue); background: var(--blue-50); box-shadow: 0 0 0 3px rgba(29,95,191,.08); }
.choice:focus-within { outline: 3px solid var(--blue-100); outline-offset: 1px; }
.choice .ic { flex: 0 0 44px; height: 44px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; color: var(--navy); }
.choice.selected .ic { background: #fff; }
.choice .tick { position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--line); background: #fff; display: grid; place-items: center; }
.choice.radio .tick { border-radius: 50%; }
.choice.selected .tick { background: var(--blue); border-color: var(--blue); }
.choice.selected .tick::after { content: ""; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.choice h3 { margin: 0 0 4px; padding-right: 30px; }
.choice p { margin: 0; color: var(--muted); font-size: 14px; }
.choice.is-disabled { opacity: .55; cursor: not-allowed; }
.counter { display: inline-flex; align-items: center; gap: 8px; background: var(--blue-50); color: var(--navy); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; margin-top: 14px; }

/* ---------- Course cards ---------- */
.group { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; background: #fff; }
.group > summary { list-style: none; cursor: pointer; padding: 14px 16px; background: var(--bg); display: flex; gap: 10px; align-items: center; font-weight: 700; color: var(--navy); }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: "▾"; margin-left: auto; transition: transform .2s; }
.group:not([open]) > summary::after { transform: rotate(-90deg); }
.group .chip { font-weight: 600; }
.group-body { padding: 14px; display: grid; gap: 12px; }
.course { border: 2px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; transition: border-color .15s, background .15s; }
.course.selected { border-color: var(--blue); background: var(--blue-50); }
.course .cb { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--navy); cursor: pointer; }
.course .title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; hyphens: auto; cursor: pointer; }
.course .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.course .meta span { white-space: nowrap; }
.course .calc { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-top: 10px; border-top: 1px dashed var(--line); }
.course .calc .total { margin-left: auto; font-weight: 700; color: var(--navy); }
.price { font-weight: 700; color: var(--navy); white-space: nowrap; }

.stepper-input { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.stepper-input button { width: 38px; border: 0; background: var(--bg); font-size: 18px; cursor: pointer; color: var(--navy); }
.stepper-input button:disabled { opacity: .4; cursor: not-allowed; }
.stepper-input input { width: 72px; border: 0; text-align: center; font: 600 15px var(--font); padding: 8px 4px; -moz-appearance: textfield; }
.stepper-input input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper-input.invalid { border-color: var(--red); }

/* ---------- Chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--bg); color: var(--navy); border: 1px solid var(--line); }
.chip.blue { background: var(--blue-50); border-color: var(--blue-100); }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-gray { background: #EEF1F4; color: #4A5565; }
.st-blue { background: var(--blue-50); color: var(--blue); }
.st-yellow { background: var(--yellow-50); color: var(--yellow); }
.st-green { background: var(--green-50); color: var(--green); }
.st-red { background: var(--red-50); color: var(--red); }

/* ---------- Alerts ---------- */
.alert { border-radius: 10px; padding: 12px 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin: 12px 0; }
.alert-info { background: var(--blue-50); border-color: var(--blue-100); color: #0F3A75; }
.alert-success { background: var(--green-50); border-color: #B8E0C8; color: #0F5C33; }
.alert-warning { background: var(--yellow-50); border-color: #F2D98F; color: #7A5210; }
.alert-error { background: var(--red-50); border-color: #F3B9B9; color: #8E1C1C; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #C9D2DD; border-radius: 9px; font: 15px var(--font); color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 13px; color: var(--red); margin-top: 4px; display: none; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); background: #FFFBFB; }
.field.invalid .err { display: block; }
.field.valid input { border-color: #8CCBA6; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 700; color: var(--navy); margin-bottom: 10px; font-size: 1rem; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.check input { width: 22px; height: 22px; accent-color: var(--green); margin: 1px 0 0; flex: 0 0 auto; }
.check.on { border-color: var(--green); background: var(--green-50); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: var(--bg); color: var(--navy); font-weight: 700; font-size: 13px; white-space: nowrap; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; background: var(--bg); color: var(--navy); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .wrap-text { min-width: 220px; overflow-wrap: anywhere; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover td { background: #FAFBFD; }

/* ---------- Summary list ---------- */
.kv { display: grid; grid-template-columns: minmax(150px, 34%) 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.review-section { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.review-section header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.review-section header h3 { margin: 0; }
.review-section header .btn-link { margin-left: auto; }
.total-box { display: flex; flex-wrap: wrap; gap: 14px 28px; background: var(--navy); color: #fff; border-radius: 10px; padding: 16px 18px; margin: 14px 0; }
.total-box div span { display: block; font-size: 13px; opacity: .8; }
.total-box div b { font-size: 1.25rem; }
.total-box .words { flex-basis: 100%; font-size: 13.5px; opacity: .9; }

/* ---------- Doc / sign blocks ---------- */
.doc-card { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--bg); }
.doc-card .doc-ic { width: 52px; height: 64px; border-radius: 6px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; color: var(--navy); font-weight: 700; font-size: 12px; }
.cert { border: 2px solid var(--line); border-radius: 10px; padding: 14px; }
.cert.ok { border-color: var(--green); background: var(--green-50); }
.cert.bad { border-color: var(--red); background: var(--red-50); }

/* ---------- Modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 22, 40, .55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.modal-head .close { margin-left: auto; background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; font: 600 14.5px var(--font); color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--navy); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; color: #fff; box-shadow: var(--shadow); font-size: 14px; animation: tin .2s ease-out; }
.toast.info { background: var(--navy); } .toast.success { background: var(--green); } .toast.error { background: var(--red); } .toast.warning { background: var(--yellow); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Cabinet / admin ---------- */
.page { padding: 24px 0 60px; }
.contract-card { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); cursor: pointer; }
.contract-card:hover { border-color: #9DB8E0; }
.contract-card .num { font-weight: 700; color: var(--navy); }
.contract-card .flags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 1.4rem; color: var(--navy); margin-top: 4px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: end; }
.toolbar .field { min-width: 160px; }
.toolbar .field.grow { flex: 1; min-width: 220px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.timeline li time { color: var(--muted); font-size: 12.5px; display: block; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
footer.site { color: var(--muted); font-size: 13px; padding: 24px 0; border-top: 1px solid var(--line); background: #fff; }
.auth-box { max-width: 460px; margin: 40px auto; }
pre.json { background: var(--bg); padding: 8px; border-radius: 6px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; max-height: 160px; overflow: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .wizard { grid-template-columns: 1fr; gap: 14px; padding-top: 12px; }
  .stepper { position: sticky; top: 60px; z-index: 20; padding: 8px; border-radius: 10px; }
  .stepper ol { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory; }
  .stepper ol::-webkit-scrollbar { display: none; }
  .stepper li { flex: 0 0 auto; padding: 6px 8px; scroll-snap-align: center; }
  .stepper li .label { display: none; }
  .stepper li.current .label { display: inline; }
  .stepper .progress { margin: 6px 4px 2px; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .panel { padding: 16px; border-radius: 10px; }
  .actions { margin: 18px -16px -16px; padding: 12px 16px; flex-wrap: wrap; }
  .actions .summary { flex-basis: 100%; order: -1; }
  .actions .btn { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .course { grid-template-columns: auto 1fr; padding: 12px; }
  .course .calc { grid-column: 1 / -1; }
  .course .calc .total { margin-left: 0; flex-basis: 100%; }
  .topbar .brand small { display: none; }
  .topnav a, .topnav button { padding: 6px 8px; font-size: 13px; }
  .topnav .user { display: none; }
  .hero { padding: 36px 0 52px; }
  .contract-card { grid-template-columns: 1fr; }
  .tbl.stack thead { display: none; }
  .tbl.stack tr { display: block; border-bottom: 1px solid var(--line); padding: 6px 0; }
  .tbl.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 12px; text-align: right; }
  .tbl.stack td::before { content: attr(data-label); color: var(--muted); font-weight: 600; text-align: left; flex: 0 0 42%; }
  .tbl.stack td.wrap-text { min-width: 0; }
  .tbl.stack tfoot tr { display: block; }
}
@media print { .topbar, .stepper, .actions, footer.site { display: none !important; } }
.cab-grid { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
@media (max-width: 860px) { .cab-grid { grid-template-columns: 1fr; } }
.admin-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
/* Мобил тузатишлар */
.wizard > * { min-width: 0; }
@media (max-width: 960px) { .wizard { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .course .meta span { white-space: normal; }
  .tbl.stack tr.grp td { display: block; text-align: left; }
  .tbl.stack tr.grp td::before { content: none; }
}
html, body { overflow-x: hidden; }
