/* Заказ текстом: экраны ord_new, ord_my, ord_review. Цвета — переменные темы из styles.css. */

.ord-page {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 760px;
    margin: 0 auto;
    padding-bottom: calc(90px + env(safe-area-inset-bottom));   /* под нижней панелью приложения */
}
.ord-page.wide { max-width: 1280px; }

.ord-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #dfe5df);
    border-radius: var(--radius, 14px);
    box-shadow: var(--shadow, 0 2px 8px rgba(22,38,22,.07));
    padding: 12px 14px;
}

.ord-card-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 8px;
}

.ord-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary, #667066);
    margin: 8px 0 4px;
}
.ord-label:first-child { margin-top: 0; }

.ord-input,
.ord-textarea,
.ord-select {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid var(--border-strong, #cfd8cf);
    border-radius: 10px;
    background: #fff;
    color: var(--text, #182018);
    font-size: 15px;
    font-family: inherit;
}
.ord-textarea { resize: vertical; line-height: 1.45; min-height: 120px; }
.ord-select { text-align: left; cursor: pointer; }
.ord-select.empty { color: var(--text-secondary, #667066); }
button.ord-select { background: #fff; }

.ord-row3 {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 8px;
}

.ord-hint {
    font-size: 13px;
    color: var(--text-secondary, #667066);
    margin-top: 6px;
    line-height: 1.4;
}

.ord-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}
.ord-actions.top { justify-content: flex-start; }
.ord-actions button { padding: 10px 14px; font-size: 14px; border-radius: 10px; }
.ord-actions.sticky {
    position: sticky;
    bottom: calc(66px + env(safe-area-inset-bottom));          /* над нижней панелью приложения */
    background: var(--bg, #f5f3df);
    padding: 8px 0;
    z-index: 2;
}

button.ord-primary { background: var(--primary, #2f6f2b); color: #fff; font-weight: 600; }
button.ord-danger { background: #fff; color: #b3261e; border: 1px solid #e6b8b4; }
button:disabled { opacity: .55; cursor: default; }

/* ---------- чипы статусов ---------- */

.ord-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: #eef1ee;
    color: #4d574d;
}
.ord-chip.small { font-size: 11px; padding: 1px 7px; font-weight: 500; }
.ord-chip.ok { background: #e3f1e0; color: #24601f; }
.ord-chip.check { background: #e4edf8; color: #1f4f8a; }
.ord-chip.wait { background: #f3f0dc; color: #6b5d12; }
.ord-chip.warn { background: #fdf0d4; color: #8a5a00; }
.ord-chip.bad { background: #fbe4e2; color: #9f231b; }
.ord-chip.info { background: #ece8f6; color: #4a3a85; }
.ord-chip.off { background: #eeeeee; color: #777; }

/* ---------- списки ---------- */

.ord-list-item { cursor: pointer; transition: box-shadow .15s; }
.ord-list-item:hover { box-shadow: var(--shadow-hover, 0 6px 16px rgba(22,38,22,.11)); }
.ord-list-item.late { border-left: 4px solid #e0a030; }
.ord-wait { font-weight: 600; }
.ord-wait.late { color: #b06d00; }
.ord-note.ord-busy { background: #ece8f6; color: #3d2f75; }
.ord-note.ord-blocked { background: #fbe4e2; color: #8e1f17; }
.ord-add-form.hidden, .ord-modal .hidden { display: none; }
.ord-add-name { font-size: 15px; margin-bottom: 8px; }
.ord-cp-head { display: flex; justify-content: space-between; align-items: flex-end; }
.ord-check { font-size: 13px; display: inline-flex; align-items: center; cursor: pointer; user-select: none; margin-bottom: 4px; }
.ord-check input { width: 18px; height: 18px; margin: 0 6px 0 0; accent-color: var(--primary, #2f6f2b); }
.ord-add-form .ord-actions { margin-top: 10px; }
.ord-link-btn.secondary { background: var(--surface, #fff); color: var(--primary, #2f6f2b); border: 1px solid var(--border, #dfe5df); }
.ord-note.ord-busy .btn-secondary { margin-left: 8px; padding: 4px 10px; font-size: 13px; }

.ord-list-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.ord-list-top > span { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ord-big { font-size: 17px; }

.ord-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary, #667066);
}

.ord-empty { padding: 18px; text-align: center; color: var(--text-secondary, #667066); }
.ord-empty.bad { color: #9f231b; }

.ord-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.ord-tab {
    background: #fff;
    color: var(--text, #182018);
    border: 1px solid var(--border-strong, #cfd8cf);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
}
.ord-tab.active { background: var(--primary, #2f6f2b); color: #fff; border-color: var(--primary, #2f6f2b); }
.ord-tab.hidden { display: none; }
.ord-tab.bad { border-color: #d23c30; color: #9f231b; background: #fbe4e2; }
.ord-tab.bad.active { background: #c0392b; color: #fff; }

.ord-note {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #eef1ee;
    font-size: 13px;
}
.ord-note.warn { background: #fdf0d4; color: #6e4800; }

.ord-order-comment {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-muted, #faf9ef);
    font-size: 14px;
}

/* ---------- выбор дня ---------- */

.ord-day {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ord-day-btn {
    background: #fff;
    color: var(--text, #182018);
    border: 1px solid var(--border-strong, #cfd8cf);
    border-radius: 10px;
    width: 42px;
    height: 40px;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    flex: none;
}
.ord-day-pick {
    position: relative;
    flex: 1;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--border-strong, #cfd8cf);
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.ord-day-pick input {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;                 /* не inset: в браузере 1С его нет */
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
}
.ord-day .ord-day-today {
    background: var(--primary, #2f6f2b);
    color: #fff;
    border: none;
    font-weight: 600;
    border-radius: 10px;
    height: 40px;
    padding: 0 12px;
    flex: none;
}
.ord-day .ord-day-today.hidden { display: none; }
.ord-tab-n { font-weight: 700; }

/* ---------- просмотр менеджера ---------- */

.ord-view-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border, #dfe5df);
}
.ord-view-line:last-child { border-bottom: none; }
.ord-view-line.missing .ord-view-name { color: #9f231b; }
.ord-view-name { font-weight: 600; }
.ord-view-qty { font-weight: 600; white-space: nowrap; }
.ord-view-src { grid-column: 1 / -1; font-size: 12px; color: var(--text-secondary, #667066); }

.ord-raw summary { cursor: pointer; font-weight: 600; }
.ord-raw .ord-textarea { margin: 8px 0; }

/* ---------- карточка оператора ---------- */

.ord-split {
    display: grid;
    grid-template-columns: minmax(220px, 300px) 1fr;
    gap: 10px;
    align-items: start;
}

.ord-src { position: sticky; top: 8px; }
.ord-src-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 10px;
    max-height: 60vh;
    overflow: auto;
}

.ord-lines-head,
.ord-line {
    display: grid;
    grid-template-columns: 12px minmax(200px, 1fr) 80px 100px minmax(120px, .6fr) 32px;
    gap: 6px;
    align-items: start;
}
.ord-lines-head {
    font-size: 12px;
    color: var(--text-secondary, #667066);
    padding: 0 6px 4px;
}

.ord-line {
    padding: 8px 6px;
    border-top: 1px solid var(--border, #dfe5df);
    border-radius: 8px;
}

/* кружок соответствия в начале строки (строки не подсвечиваются) */
.ord-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #b8bfb8;
    flex: none;
}
.ord-dot.ok { background: #3e9b3a; }
.ord-dot.warn { background: #e0a21b; }
.ord-dot.info { background: #4a72c4; }
.ord-dot.bad { background: #d23c30; }
.ord-dot.mgr { background: #8a5cc7; }
.ord-card.ord-addon { background: #fff4e3; border-color: #f0c98a; }
.ord-addon-mark { font-size: 12px; font-weight: 700; color: #9a5b00; margin-bottom: 4px; }
.ord-addon-title { font-size: 14px; font-weight: 700; color: #9a5b00; margin-bottom: 6px; }
.ord-addon-title span { font-weight: 400; color: #7a5a2a; }
.ord-addon-row { padding: 6px 0; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--border, #eef1ee); }
.ord-addon-row .ord-chip { margin-left: 6px; }
.ord-chip.mgr { background: #efe7fa; color: #5b3596; }
.ord-my-ed-line { padding: 10px 0; border-bottom: 1px solid var(--border, #eef1ee); }
.ord-my-ed-top { display: flex; align-items: center; gap: 8px; }
.ord-my-ed-top .ord-item-btn { flex: 1; }
.ord-my-ed-fields { display: grid; grid-template-columns: 90px 90px 1fr; gap: 6px; margin-top: 6px; }
.ord-my-edit-btns { margin-top: 10px; }
@media (max-width: 420px) { .ord-my-ed-fields { grid-template-columns: 1fr 1fr; } .ord-my-ed-fields [data-f="comment"] { grid-column: 1 / -1; } }
.ord-line > .ord-dot { margin-top: 12px; cursor: help; }

.ord-count { font-size: 13px; font-weight: 500; color: var(--text, #182018); white-space: nowrap; }
.ord-count .ord-dot, .ord-legend .ord-dot { margin-right: 5px; vertical-align: -1px; }
.ord-legend { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text-secondary, #667066); }
.ord-legend > span { margin-left: 12px; white-space: nowrap; }

.ord-line .ord-input { padding: 7px 8px; font-size: 14px; }
.ord-input.bad { border-color: #c0392b; background: #fdf1f0; }

.ord-item-btn {
    width: 100%;
    text-align: left;
    background: #fff;
    color: var(--text, #182018);
    border: 1px solid var(--border-strong, #cfd8cf);
    border-radius: 10px;
    padding: 7px 9px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}
.ord-item-btn.empty { color: #9f231b; font-weight: 500; }
.ord-item-btn:disabled { background: transparent; border-color: transparent; padding-left: 0; opacity: 1; }

.ord-line-src {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary, #667066);
    line-height: 1.4;
}
.ord-line-src .ord-chip { margin-right: 4px; }

/* остаток: серый — есть, жёлтый — нет, минус или меньше заказанного (подсказка, не запрет) */
.ord-stock { color: var(--text-secondary, #667066); margin-right: 8px; white-space: nowrap; }
.ord-stock.low { color: #9a6a00; }
.ord-stock.neg { color: #c0392b; font-weight: 600; }
.ord-pick small .ord-stock { margin: 0 0 0 6px; }

.ord-del {
    background: transparent;
    color: #9f231b;
    font-size: 15px;
    padding: 6px 0;
    width: 32px;
}

.ord-add { margin-top: 10px; }

/* ---------- модальные окна ---------- */

.ord-modal-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;                 /* не inset: в браузере 1С его нет */
    background: rgba(20, 30, 20, .4);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 12px 12px;
    z-index: 1000;
}
.ord-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.ord-modal-head { display: flex; justify-content: space-between; align-items: center; }
.ord-x { background: transparent; color: var(--text, #182018); font-size: 18px; padding: 2px 6px; }

.ord-pick-list { overflow: auto; margin: 0 -4px; }
.ord-pick {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    cursor: pointer;
}
.ord-pick:hover { background: var(--primary-soft, #eaf3e8); }
.ord-pick.current { background: var(--primary-soft, #eaf3e8); font-weight: 600; }
.ord-pick small { color: var(--text-secondary, #667066); white-space: nowrap; }
.ord-pick-note { font-size: 12px; color: var(--text-secondary, #667066); padding: 2px 8px 4px; }

/* ---------- кнопка-ссылка (в 1С ссылки v8:… открывают документы) и окно вопроса ---------- */

a.ord-link-btn {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--primary-soft, #eaf3e8);
    color: var(--primary, #2f6f2b);
    border: 1px solid var(--primary, #2f6f2b);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}
.ord-modal.small { max-width: 380px; }
.ord-ask-text { font-size: 15px; line-height: 1.45; margin: 4px 0 10px; white-space: pre-line; }
.ord-similar a { color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

/* ---------- уведомления ---------- */

.ord-toast {
    position: fixed;
    left: 50%;
    bottom: 84px;
    transform: translate(-50%, 20px);
    opacity: 0;
    background: #263326;
    color: #fff;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 1100;
    transition: .25s;
    max-width: calc(100vw - 32px);
}
.ord-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ord-toast.ok { background: #24601f; }
.ord-toast.bad { background: #9f231b; }

/* ---------- телефон ---------- */

@media (max-width: 820px) {
    .ord-split { grid-template-columns: 1fr; }
    .ord-src { position: static; }
    .ord-src-text { max-height: 30vh; }
    .ord-lines-head { display: none; }
    .ord-line {
        grid-template-columns: 12px 1fr 1fr 32px;
        grid-template-areas:
            "dot item item del"
            ". qty unit unit"
            ". com com com";
        padding: 10px 6px;
    }
    .ord-line > .ord-dot { grid-area: dot; }
    .ord-legend { display: none; }
    .ord-line-item { grid-area: item; }
    .ord-line .ord-qty { grid-area: qty; }
    .ord-line .ord-unit { grid-area: unit; }
    .ord-line .ord-comment { grid-area: com; }
    .ord-line .ord-del,
    .ord-line > span:last-child { grid-area: del; }
}

@media (max-width: 480px) {
    .ord-row3 { grid-template-columns: 1fr 1fr; }
    .ord-row3 > div:first-child { grid-column: 1 / -1; }
    .ord-actions button { flex: 1 1 auto; }
}

/* ---------- информация по заказам и статистика (ord_info, ord_stats) ---------- */

.ost-entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ost-entry {
    display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 6px;
    padding: 18px; cursor: pointer; font: inherit; color: inherit;
    background: var(--surface, #fff); border: 1px solid var(--border, #dfe5df);
    border-radius: var(--radius, 14px); box-shadow: var(--shadow, 0 2px 8px rgba(22,38,22,.07));
    transition: transform .12s, box-shadow .12s;
}
.ost-entry:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(22,38,22,.12); }
.ost-entry-icon { font-size: 28px; }
.ost-entry-title { font-size: 17px; font-weight: 700; }
.ost-entry-text { font-size: 13px; opacity: .75; line-height: 1.4; }
.ost-entry-n { font-size: 13px; font-weight: 600; color: var(--primary, #2f6f2b); min-height: 18px; }

.ost-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.ost-custom { display: flex; align-items: center; gap: 6px; }
.ost-custom.hidden { display: none; }
.ost-custom .ord-input { width: 150px; padding: 7px 8px; }
.ost-period { font-size: 13px; opacity: .7; margin-left: auto; }
.ost-muted { font-size: 12px; opacity: .65; font-weight: 400; }
.ost-foot { text-align: center; padding: 4px 0 8px; }

.ost-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ost-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
    padding: 14px 16px; font: inherit; color: inherit; cursor: pointer;
    background: var(--surface, #fff); border: 1px solid var(--border, #dfe5df);
    border-radius: var(--radius, 14px); box-shadow: var(--shadow, 0 2px 8px rgba(22,38,22,.07));
    border-top: 4px solid #c8d8c6;
}
.ost-tile:disabled { cursor: default; }
.ost-tile.warn { border-top-color: #e0a030; }
.ost-tile.ok { border-top-color: #3f8f3a; }
.ost-tile-label { font-size: 13px; opacity: .7; }
.ost-tile-value { font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; }
.ost-tile-sub { font-size: 12px; opacity: .7; }

.ost-alert { border-left: 4px solid #e0a030; background: #fffaf0; }
.ost-stale { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; font-size: 13px; }
.ost-stale span { opacity: .75; }

.ost-pipe { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #eef1ee; }
.ost-pipe.big { height: 22px; border-radius: 8px; }
.ost-pipe-seg { display: block; height: 100%; min-width: 3px; }
.ost-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.ost-legend.inline { display: inline-flex; margin: 0 0 0 auto; font-weight: 400; }
.ost-leg {
    display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; color: inherit;
    background: none; border: 0; padding: 0; cursor: pointer;
}
span.ost-leg { cursor: default; }
.ost-leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ost-now { margin-top: 10px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.ost-times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ost-time { padding: 10px 12px; border-radius: 10px; background: var(--surface-muted, #f6f8f5); }
.ost-time-label { font-size: 13px; font-weight: 600; display: flex; flex-direction: column; }
.ost-time-label small { font-weight: 400; opacity: .65; font-size: 11px; }
.ost-time-value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.ost-time-sub { font-size: 12px; opacity: .65; }

.ost-days { display: flex; align-items: flex-end; gap: 4px; height: 150px; overflow-x: auto; padding-bottom: 2px; }
.ost-day { flex: 1 0 22px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.ost-day-n { font-size: 10px; opacity: .7; height: 14px; }
.ost-day-bar { position: relative; flex: 1; width: 70%; max-width: 34px; }
.ost-day-all, .ost-day-ok { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 4px 4px 0 0; }
.ost-day-all { background: #c8d8c6; }
.ost-day-ok { background: #3f8f3a; }
.ost-day-d { font-size: 10px; opacity: .7; margin-top: 4px; white-space: nowrap; }

.ost-table-wrap { overflow-x: auto; margin: 0 -4px; }
.ost-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ost-table th {
    text-align: left; font-size: 12px; font-weight: 600; opacity: .7; padding: 6px 8px;
    border-bottom: 1px solid var(--border, #dfe5df); white-space: nowrap; cursor: pointer; user-select: none;
}
.ost-table th.sorted { opacity: 1; color: var(--primary, #2f6f2b); }
.ost-table td { padding: 8px; border-bottom: 1px solid var(--border, #eef1ee); white-space: nowrap; }
.ost-table td:first-child { white-space: normal; min-width: 160px; }
.ost-table.click tbody tr { cursor: pointer; }
.ost-table.click tbody tr:hover { background: var(--surface-muted, #f6f8f5); }
.ost-mini { height: 4px; border-radius: 2px; background: #eef1ee; margin-top: 4px; max-width: 160px; overflow: hidden; }
.ost-mini span { display: block; height: 100%; background: #3f8f3a; }

.ost-orders { max-height: 65vh; overflow-y: auto; }
.ost-order { padding: 8px 2px; border-bottom: 1px solid var(--border, #eef1ee); }
.ost-order-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

@media (max-width: 700px) {
    .ost-entry-grid { grid-template-columns: 1fr; }
    .ost-tiles { grid-template-columns: 1fr 1fr; }
    .ost-tile-value { font-size: 28px; }
    .ost-times { grid-template-columns: 1fr; }
    .ost-period { margin-left: 0; width: 100%; }
    .ost-custom .ord-input { width: 135px; }
}
